Skip to main content

FttsqWriter

Struct FttsqWriter 

Source
pub struct FttsqWriter { /* private fields */ }
Expand description

Builds a .fttsq artifact.

Sections are appended in the order given; the writer computes each digest and lays out absolute offsets, so a caller cannot produce an artifact whose directory disagrees with its payload.

Implementations§

Source§

impl FttsqWriter

Source

pub fn new( model_family: impl Into<String>, source_sha256: impl Into<String>, ) -> Self

Starts an artifact for one model family, converted from a checkpoint with source_sha256.

Source

pub fn license_notice(self, notice: impl Into<String>) -> Self

Sets the Apache-2.0 §4 attribution notice. Required — FttsqWriter::finish refuses without it.

Source

pub fn model_config(self, config: Value) -> Self

Attaches the frozen upstream model config.

Source

pub fn quantization_manifest(self, manifest: Value) -> Self

Attaches the per-tensor quantization policy the license notice refers to.

Source

pub fn section( self, name: impl Into<String>, access_class: AccessClass, payload: Vec<u8>, ) -> Self

Appends a section with its payload. Offset and digest are computed at FttsqWriter::finish.

Source

pub fn tensor(self, tensor: TensorEntry) -> Self

Declares a tensor located inside an already-added section.

Source

pub fn finish(self) -> Result<Vec<u8>, FttsqError>

Serializes the artifact.

The result is re-parsed before being returned, so a writer bug surfaces here rather than as an unreadable multi-gigabyte file discovered hours later.

§Errors

Returns FttsqError::LicenseNoticeMissing without a notice, or whatever the validating re-parse rejects.

Source

pub fn write_to_path(self, path: &Path) -> Result<(), FttsqError>

Serializes and writes the artifact to path atomically.

Writes to a temporary file beside the destination, fsyncs it, then renames over the target. A reader therefore observes either the previous artifact or the complete new one, never a half-written prefix — which matters because a truncated .fttsq is exactly the shape that digest verification would report as corruption rather than as an interrupted write.

The temporary lives in the destination’s own directory so the rename stays within one filesystem; rename across mount points is not atomic and would silently degrade to a copy. On failure the temporary is removed.

§Errors

Returns FttsqError::Io naming the operation and path, or whatever FttsqWriter::finish rejects.

Trait Implementations§

Source§

impl Debug for FttsqWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FttsqWriter

Source§

fn default() -> FttsqWriter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.