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: StringStable schema marker.
profile_digest: StringProfile digest.
codebook_digest: StringCodebook digest.
rotation_digest: StringRotation digest.
ambient_dim: u32Ambient dimension.
block_dim: u32Block dimension.
norm_format: NormFormatNorm payload format.
norm_payload: Vec<u8>Norm bytes.
wire_index_bits: u8Bits per fixed-rate index.
block_count: u32Number of indices.
indices: Vec<u8>Packed fixed-rate indices.
Implementations§
Source§impl FibCodeV1
impl FibCodeV1
Sourcepub fn to_compact_bytes(&self) -> Vec<u8> ⓘ
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.
Sourcepub fn from_compact_bytes(
bytes: &[u8],
profile: &FibQuantProfileV1,
) -> Result<Self>
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.
Sourcepub fn compact_size(&self) -> usize
pub fn compact_size(&self) -> usize
Compact size in bytes (does not allocate).
Sourcepub fn to_compact_v2_bytes(&self, flags: CompactFeatureFlags) -> Vec<u8> ⓘ
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.
Sourcepub fn from_compact_v2_bytes(
bytes: &[u8],
profile: &FibQuantProfileV1,
) -> Result<(Self, CompactFeatureFlags)>
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<'de> Deserialize<'de> for FibCodeV1
impl<'de> Deserialize<'de> for FibCodeV1
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for FibCodeV1
impl StructuralPartialEq for FibCodeV1
Auto Trait Implementations§
impl Freeze for FibCodeV1
impl RefUnwindSafe for FibCodeV1
impl Send for FibCodeV1
impl Sync for FibCodeV1
impl Unpin for FibCodeV1
impl UnsafeUnpin for FibCodeV1
impl UnwindSafe for FibCodeV1
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.