Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.debug
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memwatch
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.crypto
core.crypto.keys
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.encoding.xml
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.io

BinaryReader
BinaryReader :: struct {
    stream: &Stream
}
BinaryWriter
BinaryWriter :: struct {
    stream: &Stream
}
BufferStream
BufferStream :: struct {
    stream: Stream
    data: [..] u8
    curr_pos: i32
    write_enabled: bool
    fixed: bool
}
Reader
Reader :: struct {
    stream: &Stream
    buffer: [] u8
    buffer_allocator: Allocator
    start: u32
    end: u32
    last_byte: i32
    error: Error
    done: bool
    newline_format: NewLineFormat
}
Methods
Reader.advance_line
Reader.advance_line :: (reader: &Reader) -> void
Reader.empty
Reader.empty :: (reader: &Reader) -> bool
Reader.ensure_buffered
Reader.ensure_buffered :: (reader: &Reader, bytes: u32) -> Error
Reader.free
Reader.free :: (reader: &Reader) -> void
Reader.from_string
Reader.from_string :: (s: [] u8) -> (Reader, &BufferStream)
Reader.get_buffered
Reader.get_buffered :: (reader: &Reader) -> i32
Reader.is_empty
Reader.is_empty :: (reader: &Reader) -> bool
Reader.lines
Reader.lines :: (r: &Reader, inplace: bool, allocator: Allocator) -> Iterator([] u8)
Reader.make
Reader.make :: (s: &Stream, buffer_size: i32, allocator: Allocator, newline_format: NewLineFormat) -> Reader
Reader.peek_byte
Reader.peek_byte :: (reader: &Reader, advance: i32) -> (u8, Error)
Reader.peek_bytes
Reader.peek_bytes :: (reader: &Reader, advance: u32, length: u32) -> ([] u8, Error)
Reader.read_all
Reader.read_all :: (reader: &Reader, allocator: Allocator) -> [] u8
Reader.read_byte
Reader.read_byte :: (reader: &Reader) -> u8
Reader.read_bytes
Reader.read_bytes :: (reader: &Reader, bytes: [] u8) -> (i32, Error)
Reader.read_fill_buffer
Reader.read_fill_buffer :: (reader: &Reader, bytes: [] u8) -> Error
Reader.read_i32
Reader.read_i32 :: (reader: &Reader) -> i32
Reader.read_i64
Reader.read_i64 :: (reader: &Reader) -> i64
Reader.read_line
Reader.read_line :: (reader: &Reader, consume_newline: bool, allocator: Allocator, inplace: bool) -> [] u8
Reader.read_string
Reader.read_string :: (reader: &Reader, bytes: i32, allocator: Allocator) -> [] u8
Reader.read_u32
Reader.read_u32 :: (reader: &Reader) -> u32
Reader.read_u64
Reader.read_u64 :: (reader: &Reader) -> u64
Reader.read_until
Reader.read_until :: (reader: &Reader, until: u8, skip: u32, allocator: Allocator, consume_end: bool, inplace: bool) -> [] u8
Reader.read_word
Reader.read_word :: (reader: &Reader, numeric_allowed: bool, allocator: Allocator, inplace: bool) -> [] u8
Reader.reset
Reader.reset :: (reader: &Reader) -> void
Reader.skip_bytes
Reader.skip_bytes :: (reader: &Reader, bytes: u32) -> (i32, Error)
Reader.skip_whitespace
Reader.skip_whitespace :: (reader: &Reader) -> void
Reader.unread_byte
Reader.unread_byte :: (reader: &Reader) -> Error
Stream
Stream :: struct {
    vtable: &Stream_Vtable
    flags: Stream_Flags
}
Stream_Vtable
Stream_Vtable :: struct {
    seek: (&Stream, i32, SeekFrom) -> Error
    tell: (&Stream) -> Result(u32, Error)
    read: (&Stream, [] u8) -> Result(u32, Error)
    read_at: (&Stream, u32, [] u8) -> Result(u32, Error)
    read_byte: (&Stream) -> Result(u8, Error)
    write: (&Stream, [] u8) -> Result(u32, Error)
    write_at: (&Stream, u32, [] u8) -> Result(u32, Error)
    write_byte: (&Stream, u8) -> Error
    close: (&Stream) -> Error
    flush: (&Stream) -> Error
    size: (&Stream) -> i32
    poll: (&Stream, PollEvent, i32) -> Result(bool, Error)
}
Writer
Writer :: struct {
    stream: &Stream
    error: Error
    buffer: [] u8
    buffer_filled: u32
}
Methods
Writer.consume_error
Writer.consume_error :: (w: &Writer) -> Error
Writer.flush
Writer.flush :: (w: &Writer) -> void
Writer.free
Writer.free :: (w: &Writer) -> void
Writer.make
Writer.make :: (s: &Stream, buffer_size: i32) -> Writer
Writer.remaining_capacity
Writer.remaining_capacity :: (w: &Writer) -> u32
Writer.write
Writer.write :: (writer: &Writer, s: [] u8) -> void
Writer.write :: (writer: &Writer, cs: [&] u8) -> void
Writer.write :: (writer: &Writer, n: i32, base: u32) -> void
Writer.write :: (writer: &Writer, f: f32) -> void
Writer.write :: (writer: &Writer, n: i64, base: u64) -> void
Writer.write :: (writer: &Writer, f: f64) -> void
Writer.write :: (writer: &Writer, b: bool) -> void
Writer.write :: (writer: &Writer, p: &void) -> void
Writer.write :: (writer: &Writer, r: range, sep: [] u8) -> void
Writer.write :: (writer: &Writer, format: [] u8, va: ..any) -> void
Writer.write :: macro (w: &Writer, a: $T) -> void
Writer.write_bool
Writer.write_bool :: (writer: &Writer, b: bool) -> void
Writer.write_byte
Writer.write_byte :: (writer: &Writer, byte: u8) -> void
Writer.write_cstr
Writer.write_cstr :: (writer: &Writer, cs: [&] u8) -> void
Writer.write_escaped_str
Writer.write_escaped_str :: (writer: &Writer, s: [] u8) -> void
Writer.write_f32
Writer.write_f32 :: (writer: &Writer, f: f32) -> void
Writer.write_f64
Writer.write_f64 :: (writer: &Writer, f: f64) -> void
Writer.write_format
Writer.write_format :: (writer: &Writer, format: [] u8, va: ..any) -> void
Writer.write_format_va
Writer.write_format_va :: (writer: &Writer, format: [] u8, va: [] any) -> void
Writer.write_i32
Writer.write_i32 :: (writer: &Writer, n: i32, base: u32) -> void
Writer.write_i64
Writer.write_i64 :: (writer: &Writer, n: i64, base: u64) -> void
Writer.write_ptr
Writer.write_ptr :: (writer: &Writer, p: &void) -> void
Writer.write_range
Writer.write_range :: (writer: &Writer, r: range, sep: [] u8) -> void
Writer.write_str
Writer.write_str :: (writer: &Writer, s: [] u8) -> void
Error
Error :: enum {
    None :: 0
    NotImplemented :: 1
    EOF :: 2
    NoVtable :: 3
    OutOfBounds :: 4
    NotFound :: 5
    BadFile :: 6
    BufferFull :: 7
    NoProgress :: 8
    InvalidUnread :: 9
    ReadPending :: 10
    ReadLater :: 11
    ConnectFailed :: 12
    NoData :: 13
    CreationFailed :: 14
    OperationFailed :: 15
}
PollEvent
PollEvent :: enum {
    None :: 0
    Read :: 1
    Write :: 2
    Closed :: 3
}
SeekFrom
SeekFrom :: enum {
    Start :: 0
    Current :: 1
    End :: 2
}
Stream_Flags
Stream_Flags :: enum #flags {
    Block_On_Read :: 1
}
advance_line
advance_line :: (reader: &Reader) -> void
binary_read
binary_read :: (br: &BinaryReader, $T: type_expr) -> T
binary_read_byte
binary_read_byte :: (br: &BinaryReader) -> u8
binary_read_slice
binary_read_slice :: (br: &BinaryReader, $T: type_expr, size, read_size, allocator) -> [] T
binary_reader_make
binary_reader_make :: (s: &Stream) -> BinaryReader
binary_write
binary_write :: (bw: &BinaryWriter, $T: type_expr, v: &T) -> void
binary_write_byte
binary_write_byte :: (bw: &BinaryWriter, byte: u8) -> void
binary_write_slice
binary_write_slice :: (bw: &BinaryWriter, sl: [] $T, output_size) -> void
binary_writer_make
binary_writer_make :: (s: &Stream) -> BinaryWriter
buffer_stream_free
buffer_stream_free :: (bs: &BufferStream) -> void
buffer_stream_make
buffer_stream_make :: (initial_data: [] u8, allocator: Allocator, fixed: bool, write_enabled: bool) -> BufferStream
buffer_stream_make :: (initial_size: i32, allocator: Allocator) -> BufferStream
buffer_stream_to_str
buffer_stream_to_str :: (bs: &BufferStream) -> [] u8
lines
lines :: (r: &Reader, inplace: bool, allocator: Allocator) -> Iterator([] u8)
peek_byte
peek_byte :: (reader: &Reader, advance: i32) -> (u8, Error)
peek_bytes
peek_bytes :: (reader: &Reader, advance: u32, length: u32) -> ([] u8, Error)
read_all
read_all :: (reader: &Reader, allocator: Allocator) -> [] u8
read_byte
read_byte :: (reader: &Reader) -> u8
read_bytes
read_bytes :: (reader: &Reader, bytes: [] u8) -> (i32, Error)
read_fill_buffer
read_fill_buffer :: (reader: &Reader, bytes: [] u8) -> Error
read_i32
read_i32 :: (reader: &Reader) -> i32
read_i64
read_i64 :: (reader: &Reader) -> i64
read_line
read_line :: (reader: &Reader, consume_newline: bool, allocator: Allocator, inplace: bool) -> [] u8
read_string
read_string :: (reader: &Reader, bytes: i32, allocator: Allocator) -> [] u8
read_u32
read_u32 :: (reader: &Reader) -> u32
read_u64
read_u64 :: (reader: &Reader) -> u64
read_until
read_until :: (reader: &Reader, until: u8, skip: u32, allocator: Allocator, consume_end: bool, inplace: bool) -> [] u8
read_word
read_word :: (reader: &Reader, numeric_allowed: bool, allocator: Allocator, inplace: bool) -> [] u8
reader_empty
reader_empty :: (reader: &Reader) -> bool
reader_ensure_buffered
reader_ensure_buffered :: (reader: &Reader, bytes: u32) -> Error
reader_free
reader_free :: (reader: &Reader) -> void
reader_from_string
reader_from_string :: (s: [] u8) -> (Reader, &BufferStream)
reader_get_buffered
reader_get_buffered :: (reader: &Reader) -> i32
reader_make
reader_make :: (s: &Stream, buffer_size: i32, allocator: Allocator, newline_format: NewLineFormat) -> Reader
reader_reset
reader_reset :: (reader: &Reader) -> void
skip_bytes
skip_bytes :: (reader: &Reader, bytes: u32) -> (i32, Error)
skip_whitespace
skip_whitespace :: (reader: &Reader) -> void
stream_close
stream_close :: (s: &Stream) -> Error
stream_flush
stream_flush :: (s: &Stream) -> Error
stream_poll
stream_poll :: (s: &Stream, ev: PollEvent, timeout: i32) -> Result(bool, Error)

Waits until a stream is able to be read from or written to.

If timeout < 0, then there is an indefinite timeout.

If timeout = 0, then there is no timeout, and this function returns immediately.

If timeout > 0, then there is a timeout millisecond delay before returning false.

stream_read
stream_read :: (s: &Stream, buffer: [] u8) -> Result(u32, Error)
stream_read_at
stream_read_at :: (s: &Stream, at: u32, buffer: [] u8) -> Result(u32, Error)
stream_read_byte
stream_read_byte :: (s: &Stream) -> Result(u8, Error)
stream_read_until_full
stream_read_until_full :: (s: &Stream, buffer: [] u8) -> Result(u32, Error)
stream_seek
stream_seek :: (s: &Stream, to: i32, whence: SeekFrom) -> Error
stream_size
stream_size :: (s: &Stream) -> i32
stream_tell
stream_tell :: (s: &Stream) -> Result(u32, Error)
stream_write
stream_write :: (s: &Stream, buffer: [] u8) -> Result(u32, Error)
stream_write_at
stream_write_at :: (s: &Stream, at: u32, buffer: [] u8) -> Result(u32, Error)
stream_write_byte
stream_write_byte :: (s: &Stream, byte: u8) -> Error
string_builder
string_builder :: (allocator: Allocator) -> (Writer, &BufferStream)
unread_byte
unread_byte :: (reader: &Reader) -> Error
write
write :: (writer: &Writer, s: [] u8) -> void
write :: (writer: &Writer, cs: [&] u8) -> void
write :: (writer: &Writer, n: i32, base: u32) -> void
write :: (writer: &Writer, f: f32) -> void
write :: (writer: &Writer, n: i64, base: u64) -> void
write :: (writer: &Writer, f: f64) -> void
write :: (writer: &Writer, b: bool) -> void
write :: (writer: &Writer, p: &void) -> void
write :: (writer: &Writer, r: range, sep: [] u8) -> void
write :: (writer: &Writer, format: [] u8, va: ..any) -> void
write :: macro (w: &Writer, a: $T) -> void
write_bool
write_bool :: (writer: &Writer, b: bool) -> void
write_byte
write_byte :: (writer: &Writer, byte: u8) -> void
write_cstr
write_cstr :: (writer: &Writer, cs: [&] u8) -> void
write_escaped_str
write_escaped_str :: (writer: &Writer, s: [] u8) -> void
write_f32
write_f32 :: (writer: &Writer, f: f32) -> void
write_f64
write_f64 :: (writer: &Writer, f: f64) -> void
write_format
write_format :: (writer: &Writer, format: [] u8, va: ..any) -> void
write_format_va
write_format_va :: (writer: &Writer, format: [] u8, va: [] any) -> void
write_i32
write_i32 :: (writer: &Writer, n: i32, base: u32) -> void
write_i64
write_i64 :: (writer: &Writer, n: i64, base: u64) -> void
write_ptr
write_ptr :: (writer: &Writer, p: &void) -> void
write_range
write_range :: (writer: &Writer, r: range, sep: [] u8) -> void
write_str
write_str :: (writer: &Writer, s: [] u8) -> void
writer_consume_error
writer_consume_error :: (w: &Writer) -> Error
writer_flush
writer_flush :: (w: &Writer) -> void
writer_free
writer_free :: (w: &Writer) -> void
writer_make
writer_make :: (s: &Stream, buffer_size: i32) -> Writer
writer_remaining_capacity
writer_remaining_capacity :: (w: &Writer) -> u32