BufferWriter
Module: strata.io • Kind: struct
Source: strata/io/serializer.mojo
struct BufferWriterfrom strata.io import BufferWriterByte buffer writer with endian-safe scalar and matrix serialization.
Constructors
Section titled “Constructors”def __init__(out self)Methods Overview
Section titled “Methods Overview”| 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. |
Method Details
Section titled “Method Details”BufferWriter.write_byte()
Section titled “BufferWriter.write_byte()”def write_byte(mut self, val: UInt8)Write a single byte to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
UInt8 |
— |
BufferWriter.write_bool()
Section titled “BufferWriter.write_bool()”def write_bool(mut self, val: Bool)Write a boolean value to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
Bool |
— |
BufferWriter.write_int()
Section titled “BufferWriter.write_int()”def write_int(mut self, val: Int)Write an integer to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
Int |
— |
BufferWriter.write_float64()
Section titled “BufferWriter.write_float64()”def write_float64(mut self, val: Float64)Write a 64-bit float to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
Float64 |
— |
BufferWriter.write_float32()
Section titled “BufferWriter.write_float32()”def write_float32(mut self, val: Float32)Write a 32-bit float to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
Float32 |
— |
BufferWriter.write_string()
Section titled “BufferWriter.write_string()”def write_string(mut self, val: String)Write a length-prefixed UTF-8 string to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
String |
— |
BufferWriter.write_int_list()
Section titled “BufferWriter.write_int_list()”def write_int_list(mut self, val: List[Int])Write a list of integers to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
List[Int] |
— |
BufferWriter.write_float64_list()
Section titled “BufferWriter.write_float64_list()”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] |
— |
BufferWriter.write_float_list()
Section titled “BufferWriter.write_float_list()”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]] |
— |
BufferWriter.write_matrix()
Section titled “BufferWriter.write_matrix()”def write_matrix[dtype: DType](mut self, val: Matrix[dtype])Write a dense Matrix to the buffer.
| Parameter | Type | Description |
|---|---|---|
val |
Matrix[dtype] |
— |
BufferWriter.get_bytes()
Section titled “BufferWriter.get_bytes()”def get_bytes(self) -> List[UInt8]Return the serialized byte buffer.
Returns: List[UInt8]
BufferWriter.save_to_file()
Section titled “BufferWriter.save_to_file()”def save_to_file(self, path: String)Write the serialized byte buffer to a file on disk.
| Parameter | Type | Description |
|---|---|---|
path |
String |
— |