flix

0.61.0

BufReader

Definitions

def peek(bufReader: BufReader[a, t, r]): Result[IoError, Option[Elm[t]]] \ Aef[t] + r with Readable[t] where Readable.Elm[t] ~ a Source

Returns Ok(Some(x)) where x is the next value to be read, or Ok(None) if the bufReader is empty. Does not advance the bufReader.

Returns Err(err) if there is an IO error.

def read(dest: Array[Elm[t], rb], bufReader: BufReader[a, t, rr]): Result[IoError, Int32] \ rb + rr + Aef[t] with Readable[t] where Readable.Elm[t] ~ a Source

Reads k items from the underlying Readable into dest, storing items read into the internal buffer.

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

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

Returns Err(e) if some underlying error occurs.

def readWhile(p: a -> Bool, bufReader: BufReader[a, t, r]): Result[IoError, Vector[a]] \ Aef[t] + r with Readable[t] where Readable.Elm[t] ~ a Source

Reads from reader until an element is reached that does not satisfy predicate p.

Returns Ok(vec) where vec is a vector of the first k elements where k is the index of the first element that does not satisfy p. This element is not included in the vector, and will be read on the next read.

All elements of vec are guaranteed to satisfy p.

Returns Err(err) if there is an IO error.

def skip(n: Int32, bufReader: BufReader[a, t, r]): Result[IoError, Int32] \ Aef[t] + r with Readable[t] where Readable.Elm[t] ~ a Source

Advances the reader by n, skipping over the elements without reading them.

Returns Ok(k) where k is the number of items skipped.

Guarantees that 0 <= k <= max(n, 0). If k < n, then EOF has been reached.

Returns Err(err) if there is an IO error.

def withCapacity(rc: Region[r], capacity: Int32, reader: t): BufReader[a, t, r] \ r with Readable[t] Source

Constructs a BufReader wrapping reader with the specified capacity in items.

If capacity <= 0, the BufReader will delegate directly to reader without buffering.

def withDefaultCapacity(rc: Region[r], reader: t): BufReader[a, t, r] \ r with Readable[t] Source

Constructs a BufReader wrapping reader with a default capacity of 4096 items.