file_streams/read_text_stream
Use Erlang text file read streams in Gleam.
Types
A stream that UTF-8 text can be read from.
pub type ReadTextStream
Functions
pub fn close(
stream: ReadTextStream,
) -> Result(Nil, ReadStreamError)
Closes a text stream.
pub fn open(
filename: String,
) -> Result(ReadTextStream, FileError)
Opens a new stream that reads UTF-8 text data from a file. Once the stream
is no longer needed it should be closed with close()
.
pub fn read_chars(
stream: ReadTextStream,
count: Int,
) -> Result(String, ReadStreamError)
Reads the next count
UTF-8 characters from a text stream. The returned
number of characters may be fewer than the number that was requested if the
end of the stream was reached.