pub struct BurnpackWriter { /* private fields */ }Expand description
Writer for creating Burnpack files
Implementations§
Source§impl BurnpackWriter
impl BurnpackWriter
Sourcepub fn new(snapshots: Vec<TensorSnapshot>) -> Self
pub fn new(snapshots: Vec<TensorSnapshot>) -> Self
Create a new writer
Sourcepub fn with_metadata(self, key: &str, value: &str) -> Self
pub fn with_metadata(self, key: &str, value: &str) -> Self
Builder pattern: add metadata and return self
Sourcepub fn size(&self) -> Result<usize, BurnpackError>
pub fn size(&self) -> Result<usize, BurnpackError>
Calculate the total size needed for the burnpack data
This is useful when you want to pre-allocate a buffer for write_into().
The size includes padding bytes for both metadata alignment and tensor alignment.
Sourcepub fn write_into(&self, buffer: &mut [u8]) -> Result<(), BurnpackError>
pub fn write_into(&self, buffer: &mut [u8]) -> Result<(), BurnpackError>
Write burnpack data into a caller-provided buffer
The buffer must be large enough to hold all data. Use size() to determine
the required buffer size. If the buffer is too small, this will return an error.
This allows the caller to control buffer allocation, enabling optimizations like:
- Buffer reuse across multiple writes
- Custom allocators
- Pinned memory for GPU transfers
§Arguments
buffer- Mutable slice to write data into. Must be at leastsize()bytes.
Auto Trait Implementations§
impl Freeze for BurnpackWriter
impl !RefUnwindSafe for BurnpackWriter
impl !Send for BurnpackWriter
impl !Sync for BurnpackWriter
impl Unpin for BurnpackWriter
impl !UnwindSafe for BurnpackWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more