pub struct CodecFileWriter { /* private fields */ }Expand description
Streaming writer for a Level-2 TQCV corpus file.
The file is opened with TQCX (tentative) magic and finalized to TQCV once all records have been written and the count is known.
Implementations§
Source§impl CodecFileWriter
impl CodecFileWriter
Sourcepub fn create(
path: &Path,
config_hash: &str,
dimension: u32,
bit_width: u8,
residual: bool,
metadata: &[u8],
) -> Result<Self, IoError>
pub fn create( path: &Path, config_hash: &str, dimension: u32, bit_width: u8, residual: bool, metadata: &[u8], ) -> Result<Self, IoError>
Sourcepub fn append(&mut self, cv: &CompressedVector) -> Result<(), IoError>
pub fn append(&mut self, cv: &CompressedVector) -> Result<(), IoError>
Append one CompressedVector as a length-prefixed Level-1 record.
§Errors
Returns IoError if the vector cannot be serialized or written.
Sourcepub const fn vector_count(&self) -> u64
pub const fn vector_count(&self) -> u64
Number of vectors written so far.
Sourcepub fn config_hash(&self) -> &str
pub fn config_hash(&self) -> &str
Config hash used when creating the file.
Sourcepub fn body_offset(
config_hash: &str,
metadata_len: usize,
) -> Result<usize, IoError>
pub fn body_offset( config_hash: &str, metadata_len: usize, ) -> Result<usize, IoError>
Compute the byte offset of the first record body in the file.
This mirrors the body_offset formula from [encode_header]: the
header is padded to an 8-byte boundary after the variable prefix.
§Errors
Returns IoError::InvalidHeader if the parameters would produce
an invalid header (same constraints as [encode_header]).
Auto Trait Implementations§
impl Freeze for CodecFileWriter
impl RefUnwindSafe for CodecFileWriter
impl Send for CodecFileWriter
impl Sync for CodecFileWriter
impl Unpin for CodecFileWriter
impl UnsafeUnpin for CodecFileWriter
impl UnwindSafe for CodecFileWriter
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