Skip to main content

TurboCodeWireV1

Struct TurboCodeWireV1 

Source
pub struct TurboCodeWireV1;
Expand description

Encoder/decoder for TurboCode wire format v1.

Implementations§

Source§

impl TurboCodeWireV1

Source

pub fn encode(code: &TurboCode, profile: &TurboQuantizer) -> Result<Vec<u8>>

Encode a validated TurboCode using the supplied quantizer profile.

Source

pub fn decode(bytes: &[u8], profile: &TurboQuantizer) -> Result<TurboCode>

Decode and validate TurboCode wire bytes against the supplied profile.

Source

pub fn encode_batch( codes: &[TurboCode], profile: &TurboQuantizer, ) -> Result<Vec<u8>>

Encode a batch of TurboCodes using the supplied shared quantizer profile. Convenience wrapper that uses f32 (lossless) radii.

Source

pub fn encode_batch_with_radii( codes: &[TurboCode], profile: &TurboQuantizer, radii_codec: RadiusCodecProfileV1, ) -> Result<Vec<u8>>

Encode a batch of TurboCodes using the supplied shared quantizer profile and the specified radii codec.

For a batch of N vectors at dim D, projections P, bits B, the layout is:

offset size field


0 4 magic “TQB1” 4 2 version (LE u16) 6 2 rotation flag (LE u16) 8 1 variant (= 2 for BATCH) 9 1 reserved (= 0) 10 4 dim (LE u32) 14 1 polar_bits (u8) 15 1 radii_codec (0=f32, 1=BlockLogU8) <– NEW 16 2 reserved (= 0) 18 4 qjl_projections (LE u32) 22 8 seed (LE u64) 30 4 n_vectors (LE u32) 34 4 vector_payload_len (LE u32) — size of EACH per-vector payload 38 … vector 0 payload (vector_payload_len bytes) … … vector 1 payload … … …

Per-vector payload depends on radii_codec:

  • f32 (lossless): [radii: 4*N bytes] [angles: A bytes] [signs: S bytes]
  • BlockLogU8 (lossy): [radii: 1*N + 8 bytes (min/max)] [angles] [signs]
Source

pub fn decode_batch( bytes: &[u8], profile: &TurboQuantizer, ) -> Result<Vec<TurboCode>>

Decode a batched TQB1 payload into a Vec.

Source§

impl TurboCodeWireV1

Source

pub fn parse_header(bytes: &[u8]) -> Result<TurboCodeWireHeader>

Parse just the 44-byte wire header. This is the public entry point for callers that want to extract the quantizer profile from the wire format without validating against a specific quantizer instance.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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