Skip to content

BufferReader

Module: strata.io • Kind: struct
Source: strata/io/serializer.mojo

struct BufferReader
from strata.io import BufferReader

Byte buffer reader with bounds checking and scalar/matrix deserialization.


def __init__(out self, buffer: List[UInt8])
Argument Type Description
buffer List[UInt8] —

Method Description
BufferReader.from_file() Read binary contents from disk into a BufferReader.
BufferReader.read_byte() Read a single byte from the buffer.
BufferReader.read_bool() Read a boolean value from the buffer.
BufferReader.read_int() Read an integer from the buffer.
BufferReader.read_float64() Read a 64-bit float from the buffer.
BufferReader.read_float32() Read a 32-bit float from the buffer.
BufferReader.read_string() Read a length-prefixed UTF-8 string from the buffer.
BufferReader.read_int_list() Read a list of integers from the buffer.
BufferReader.read_float64_list() Read a list of 64-bit floats from the buffer.
BufferReader.read_float_list() Read a list of floating-point scalars from the buffer.
BufferReader.read_matrix() Read a dense Matrix from the buffer.

def from_file(path: String) -> Self

Read binary contents from disk into a BufferReader.

Parameter Type Description
path String —

Returns: Self


def read_byte(mut self) -> UInt8

Read a single byte from the buffer.

Returns: UInt8


def read_bool(mut self) -> Bool

Read a boolean value from the buffer.

Returns: Bool


def read_int(mut self) -> Int

Read an integer from the buffer.

Returns: Int


def read_float64(mut self) -> Float64

Read a 64-bit float from the buffer.

Returns: Float64


def read_float32(mut self) -> Float32

Read a 32-bit float from the buffer.

Returns: Float32


def read_string(mut self) -> String

Read a length-prefixed UTF-8 string from the buffer.

Returns: String


def read_int_list(mut self) -> List[Int]

Read a list of integers from the buffer.

Returns: List[Int]


def read_float64_list(mut self) -> List[Float64]

Read a list of 64-bit floats from the buffer.

Returns: List[Float64]


def read_float_list[dtype: DType](mut self) -> List[Scalar[dtype]]

Read a list of floating-point scalars from the buffer.

Returns: List[Scalar[dtype]]


def read_matrix[dtype: DType](mut self) -> Matrix[dtype]

Read a dense Matrix from the buffer.

Returns: Matrix[dtype]