pub struct TurboCodeWireV1;Expand description
Encoder/decoder for TurboCode wire format v1.
Implementations§
Source§impl TurboCodeWireV1
impl TurboCodeWireV1
Sourcepub fn encode(code: &TurboCode, profile: &TurboQuantizer) -> Result<Vec<u8>>
pub fn encode(code: &TurboCode, profile: &TurboQuantizer) -> Result<Vec<u8>>
Encode a validated TurboCode using the supplied quantizer profile.
Sourcepub fn decode(bytes: &[u8], profile: &TurboQuantizer) -> Result<TurboCode>
pub fn decode(bytes: &[u8], profile: &TurboQuantizer) -> Result<TurboCode>
Decode and validate TurboCode wire bytes against the supplied profile.
Sourcepub fn encode_batch(
codes: &[TurboCode],
profile: &TurboQuantizer,
) -> Result<Vec<u8>>
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.
Sourcepub fn encode_batch_with_radii(
codes: &[TurboCode],
profile: &TurboQuantizer,
radii_codec: RadiusCodecProfileV1,
) -> Result<Vec<u8>>
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]
Sourcepub fn decode_batch(
bytes: &[u8],
profile: &TurboQuantizer,
) -> Result<Vec<TurboCode>>
pub fn decode_batch( bytes: &[u8], profile: &TurboQuantizer, ) -> Result<Vec<TurboCode>>
Decode a batched TQB1 payload into a Vec
Source§impl TurboCodeWireV1
impl TurboCodeWireV1
Sourcepub fn parse_header(bytes: &[u8]) -> Result<TurboCodeWireHeader>
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§
impl Freeze for TurboCodeWireV1
impl RefUnwindSafe for TurboCodeWireV1
impl Send for TurboCodeWireV1
impl Sync for TurboCodeWireV1
impl Unpin for TurboCodeWireV1
impl UnsafeUnpin for TurboCodeWireV1
impl UnwindSafe for TurboCodeWireV1
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.