flix

0.78.0

DecodingReader

struct DecodingReader[t: Type, r: Eff]Source
rc: Region[r]byteReader: tdecoder: java.nio.charset.CharsetDecodermut leftovers: Array[Int8, r]

Type of readers that decode bytes into chars.

A DecodingReader adapts a Readable of bytes to a Readable of chars.

byteReader: the underlying byte reader, an instance of Readable where Readable.Elm[t] ~ Int8. decoder: used to decode bytes read from byteReader. leftovers: stores bytes that have been consumed from byteReader but have not yet been decoded; either because they are lead bytes whose continuation bytes have not been read, or because DecodingReader overestimated the number of bytes needed to fill a char buffer.

Type of readers that decode bytes into chars, and its functions.

Instances

instance Readable[DecodingReader[t, rr]] with Readable[t] where Readable.Elm[t] ~ Int8Source
type Elm = Chartype Aef = Aef[t] + IO + rr

Definitions

def read(dest: Array[Char, rb], reader: DecodingReader[t, rr]): Result[IoError, Int32] \ IO + rr + rb + Aef[t] with Readable[t] where Readable.Elm[t] ~ Int8§ Source

Reads bytes from the underlying byteReader and decodes the result into dest.

Returns Ok(k) to signify that k chars were successfully read and written to dest.

Guarantees that 0 <= k <= length(dest).

Returns Err(e) if some underlying error occurs.

def wrap(rc: Region[rr], charset: CharacterSet, byteReader: t): DecodingReader[t, rr] \ rr + IO§ Source

Wraps byteReader in a DecodingReader.