Skip to main content

FibCodeV1

Struct FibCodeV1 

Source
pub struct FibCodeV1 {
    pub schema_version: String,
    pub profile_digest: String,
    pub codebook_digest: String,
    pub rotation_digest: String,
    pub ambient_dim: u32,
    pub block_dim: u32,
    pub norm_format: NormFormat,
    pub norm_payload: Vec<u8>,
    pub wire_index_bits: u8,
    pub block_count: u32,
    pub indices: Vec<u8>,
}
Expand description

Encoded fixed-rate FibQuant artifact.

Fields§

§schema_version: String

Stable schema marker.

§profile_digest: String

Profile digest.

§codebook_digest: String

Codebook digest.

§rotation_digest: String

Rotation digest.

§ambient_dim: u32

Ambient dimension.

§block_dim: u32

Block dimension.

§norm_format: NormFormat

Norm payload format.

§norm_payload: Vec<u8>

Norm bytes.

§wire_index_bits: u8

Bits per fixed-rate index.

§block_count: u32

Number of indices.

§indices: Vec<u8>

Packed fixed-rate indices.

Implementations§

Source§

impl FibCodeV1

Source

pub fn to_compact_bytes(&self) -> Vec<u8>

Compact binary wire format. The FibCodeV1 struct carries a lot of metadata for JSON deserialization (schema_version, profile_digest, rotation_digest, ambient_dim, block_dim, etc.) that the decoder either doesn’t need (it has its own profile) or can reconstruct from the manifest (profile_digest/codebook_digest/rotation_digest).

Compact layout (little-endian, packed): [0..3] magic: “FB1” [3] version: 1 [4] wire_index_bits [5..9] block_count (u32) [9..11] norm_payload (length-prefixed, max 65535 bytes) actually: [9..11] norm_len (u16) + norm bytes then indices bytes

The decoder must already know the profile (or have the manifest supply it). It can re-derive the digests from that profile and check them at the manifest level. Per-block we only need wire_index_bits, block_count, norm_payload, and indices.

For fib_k4_n32 with head_dim=64: 16 indices * 5 bits = 10 bytes indices + 2 bytes norm = 12 bytes payload + 11 bytes header = 23 bytes per block vs 474 bytes for JSON = 20.6x smaller.

Source

pub fn from_compact_bytes( bytes: &[u8], profile: &FibQuantProfileV1, ) -> Result<Self>

Decode the compact binary format. The caller must supply the profile so that the profile/codebook digests in the resulting FibCodeV1 match what validate_code_header expects.

The compact format omits the digests because they’re derivable from the profile — there’s no point storing them when the decoder will check them against the profile digest anyway.

Source

pub fn compact_size(&self) -> usize

Compact size in bytes (does not allocate).

Source

pub fn to_compact_v2_bytes(&self, flags: CompactFeatureFlags) -> Vec<u8>

Compact v2 binary wire format with feature flags.

Layout (little-endian, packed): [0..3] magic: “FB2” [3] version: 1 [4] feature_flags [5] wire_index_bits [6..10] block_count (u32) [10..12] norm_len (u16) [12..12+norm_len] norm bytes then indices bytes

The v2 format adds a 1-byte feature flags field at offset 4, enabling forward-compatible extensions. Unknown flags are ignored by the decoder.

Source

pub fn from_compact_v2_bytes( bytes: &[u8], profile: &FibQuantProfileV1, ) -> Result<(Self, CompactFeatureFlags)>

Decode the v2 compact binary format. Accepts any feature flags — unknown flags are silently ignored (forward compatibility). Known flags that alter the payload layout are handled.

Trait Implementations§

Source§

impl Clone for FibCodeV1

Source§

fn clone(&self) -> FibCodeV1

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FibCodeV1

Source§

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

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

impl<'de> Deserialize<'de> for FibCodeV1

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for FibCodeV1

Source§

impl PartialEq for FibCodeV1

Source§

fn eq(&self, other: &FibCodeV1) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for FibCodeV1

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FibCodeV1

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V