pub struct FttsqStreamingWriter<W> { /* private fields */ }Expand description
A bounded writer for .fttsq section payloads.
The stream owns metadata plus one incremental SHA-256 state; it never owns a section payload.
This is intentionally lower-level than FttsqWriter: callers retain responsibility for the
surrounding atomic temporary-file creation, sync, and rename, while this type finalizes the
directory only after every declared byte and digest is complete.
Implementations§
Source§impl<W: Write + Seek> FttsqStreamingWriter<W>
impl<W: Write + Seek> FttsqStreamingWriter<W>
Sourcepub fn write_section(
&mut self,
section: &str,
bytes: &[u8],
) -> Result<(), FttsqError>
pub fn write_section( &mut self, section: &str, bytes: &[u8], ) -> Result<(), FttsqError>
Appends bytes to the next declared section.
Calls for a later section are refused rather than buffered. That ordering makes the converter’s one-tensor-at-a-time memory bound mechanical: once a section is complete, its source mapping and tile buffers can be released before conversion continues.
§Errors
Returns a named refusal for out-of-order or overlong sections, or FttsqError::Io when
the caller-owned stream cannot accept the bytes.
Sourcepub fn finish(self) -> Result<W, FttsqError>
pub fn finish(self) -> Result<W, FttsqError>
Finalizes all completed section digests and rewrites the reserved directory in place.
The returned stream is positioned at its end and flushed, ready for a file-owning caller to
perform its durability and atomic-rename steps. A successful return guarantees that a
complete byte buffer collected from the stream passes FttsqReader::open.
§Errors
Refuses an incomplete declared section and names failures while seeking, finalizing, or flushing the caller-owned stream.