Skip to content

BufferWriter

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

struct BufferWriter
from strata.io import BufferWriter

Byte buffer writer with endian-safe scalar and matrix serialization.


def __init__(out self)

Method Description
BufferWriter.write_byte() Write a single byte to the buffer.
BufferWriter.write_bool() Write a boolean value to the buffer.
BufferWriter.write_int() Write an integer to the buffer.
BufferWriter.write_float64() Write a 64-bit float to the buffer.
BufferWriter.write_float32() Write a 32-bit float to the buffer.
BufferWriter.write_string() Write a length-prefixed UTF-8 string to the buffer.
BufferWriter.write_int_list() Write a list of integers to the buffer.
BufferWriter.write_float64_list() Write a list of 64-bit floats to the buffer.
BufferWriter.write_float_list() Write a list of floating-point scalars to the buffer.
BufferWriter.write_matrix() Write a dense Matrix to the buffer.
BufferWriter.get_bytes() Return the serialized byte buffer.
BufferWriter.save_to_file() Write the serialized byte buffer to a file on disk.

def write_byte(mut self, val: UInt8)

Write a single byte to the buffer.

Parameter Type Description
val UInt8 —

def write_bool(mut self, val: Bool)

Write a boolean value to the buffer.

Parameter Type Description
val Bool —

def write_int(mut self, val: Int)

Write an integer to the buffer.

Parameter Type Description
val Int —

def write_float64(mut self, val: Float64)

Write a 64-bit float to the buffer.

Parameter Type Description
val Float64 —

def write_float32(mut self, val: Float32)

Write a 32-bit float to the buffer.

Parameter Type Description
val Float32 —

def write_string(mut self, val: String)

Write a length-prefixed UTF-8 string to the buffer.

Parameter Type Description
val String —

def write_int_list(mut self, val: List[Int])

Write a list of integers to the buffer.

Parameter Type Description
val List[Int] —

def write_float64_list(mut self, val: List[Float64])

Write a list of 64-bit floats to the buffer.

Parameter Type Description
val List[Float64] —

def write_float_list[dtype: DType](mut self, val: List[Scalar[dtype]])

Write a list of floating-point scalars to the buffer.

Parameter Type Description
val List[Scalar[dtype]] —

def write_matrix[dtype: DType](mut self, val: Matrix[dtype])

Write a dense Matrix to the buffer.

Parameter Type Description
val Matrix[dtype] —

def get_bytes(self) -> List[UInt8]

Return the serialized byte buffer.

Returns: List[UInt8]


def save_to_file(self, path: String)

Write the serialized byte buffer to a file on disk.

Parameter Type Description
path String —