buffer
WriteWhileReadingError
object WriteWhileReadingError
Error raised when a buffer is written after reading has started.
OutOfBoundError
object OutOfBoundError
Error raised when a buffer index is out of bounds.
Buffer
object Buffer
Read and write data to a string buffer
init
static fun init(capacity: int = 0) > Buffer
Returns: A new Buffer
fromStr
static fun fromStr(string: str) > Buffer
Creates a buffer initialized with string.
string: Bytes to write into the new buffer Returns: A newBuffer
collect
fun collect() > void
Frees the buffer
read
fun read(n: int = 1) > str?
Reads n bytes Returns: Read bytes or null if nothing to read
write
fun write(bytes: str) > void !> WriteWhileReadingError
Writes a string
bytes: Bytes to write
writeZ
fun writeZ::<T>(zigType: str, values: [T]) > void !> FFITypeMismatchError
Writes values using a Zig type layout.
zigType: Zig type expressionvalues: Values to write
writeZAt
fun writeZAt::<T>(at: int, zigType: str, values: [T]) > void !> FFITypeMismatchError
Writes values at at using a Zig type layout.
at: Offset at which to writezigType: Zig type expressionvalues: Values to write
readZ
fun readZ::<T>(zigType: str) > T !> FFITypeMismatchError
Reads a value using a Zig type layout.
zigType: Zig type expression Returns: Read value
readZAt
fun readZAt::<T>(at: int, zigType: str) > T !> FFITypeMismatchError
Reads a value at at using a Zig type layout.
at: Offset from which to readzigType: Zig type expression Returns: Read value
writeStruct
fun writeStruct::<T>(structType: type, values: [T]) > void !> FFITypeMismatchError
Writes values using a Buzz object type as a Zig struct layout.
structType: Buzz object type to use as struct layoutvalues: Values to write
writeStructAt
fun writeStructAt::<T>(structType: type, at: int, values: [T]) > void !> FFITypeMismatchError
Writes values at at using a Buzz object type as a Zig struct layout.
structType: Buzz object type to use as struct layoutat: Offset at which to writevalues: Values to write
readStruct
fun readStruct::<T>(structType: type) > T
Reads a value using a Buzz object type as a Zig struct layout.
structType: Buzz object type to use as struct layout Returns: Read value
readStructAt
fun readStructAt::<T>(structType: type, at: int) > T
Reads a value at at using a Buzz object type as a Zig struct layout.
structType: Buzz object type to use as struct layoutat: Offset from which to read Returns: Read value
readBoolean
fun readBoolean() > bool?
Reads a boolean Returns: Boolean we read or null if nothing to read
writeBoolean
fun writeBoolean(boolean: bool) > void !> WriteWhileReadingError
Writes a boolean
boolean: Boolean to write
readInt
fun readInt() > int? !> ReadWriteError
Reads an integer Returns: Read integer or null if nothing to read
writeInt
fun writeInt(number: int) > void !> WriteWhileReadingError
Writes an integer
number: Integer to write
readUserData
fun readUserData() > ud? !> ReadWriteError
Reads an ud Returns: Read ud or null if nothing to read
writeUserData
fun writeUserData(userdata: ud) > void !> WriteWhileReadingError
Writes an ud
number: UserDataeger to write
readDouble
fun readDouble() > double? !> ReadWriteError
Reads a double Returns: Read double or null if nothing to read
writeDouble
fun writeDouble(number: double) > void !> WriteWhileReadingError
Writes a double
number: Double to write
len
fun len(align: int = 1) > int
Returns: Length of the buffer
cursor
fun cursor() > int
Returns: Position of the reading cursor
empty
fun empty() > void
Empties the buffer
toString
fun toString() > str
Get buffer as string
ptr
fun ptr(at: int = 0, align: int = 1) > ud
Get buffer's ptr
at
fun at(index: int) > int !> OutOfBoundError
Get byte at index
setAt
fun setAt(index: int, value: int) > void !> WriteWhileReadingError, OutOfBoundError
Set byte at index
