fn make_reader(r Reader) Reader
make_reader is a temp that converts a type to a reader (e.g. for use in struct initialisation) (this shouldnt need to be a thing but until coercion gets made better it is required)
fn make_readerwriter(r Reader, w Writer) ReaderWriterImpl
make_readerwriter takes a rstream and a wstream and makes an rwstream with them
fn new_buffered_reader(o BufferedReaderConfig) &BufferedReader
new_buffered_reader creates new BufferedReader
fn read_all(config ReadAllConfig) ?[]byte
read_all reads all bytes from a reader until either a 0 length read or if read_to_end_of_stream is true then the end of the stream (none
)
fn read_any(r Reader) ?[]byte
read_any reads any available bytes from a reader (until the reader returns a read of 0 length)
interface RandomWriter {
write_to(pos int, buf []byte) ?int
}
RandomWriter represents a stream of data that can be wrote to at a random pos
interface Reader {
read(mut buf []byte) ?int
}
Reader represents a stream of data that can be read
interface ReaderWriter {
read(mut buf []byte) ?int
write(buf []byte) ?int
}
ReaderWriter represents a stream that can be read from and wrote to
interface Writer {
write(buf []byte) ?int
}
Writer represents a stream of data that can be wrote to
fn (mut r BufferedReader) read(mut buf []byte) ?int
read fufills the Reader interface
fn (r BufferedReader) end_of_stream() bool
end_of_stream returns whether the end of the stream was reached
fn (mut r BufferedReader) read_line() ?string
read_line attempts to read a line from the buffered reader it will read until it finds a new line character (\n) or the end of stream
fn (mut r ReaderWriterImpl) read(mut buf []byte) ?int
fn (mut r ReaderWriterImpl) write(buf []byte) ?int
struct BufferedReaderConfig {
reader Reader
cap int = 128 * 1024
}
BufferedReaderConfig are options that can be given to a reader
struct ReadAllConfig {
reader Reader
read_to_end_of_stream bool
}
ReadAllConfig allows options to be passed for the behaviour of read_all