Skip to main content

CompressedVectorView

Struct CompressedVectorView 

Source
pub struct CompressedVectorView<'a> {
    pub format_version: u8,
    pub config_hash: &'a str,
    pub dimension: u32,
    pub bit_width: u8,
    pub packed_indices: &'a [u8],
    pub residual: Option<&'a [u8]>,
}
Expand description

A zero-copy view of a single Level-1 serialized CompressedVector.

All fields borrow from the input byte slice. No heap allocation occurs during parse or unpack_into.

fn assert_not_serialize<T: serde::Serialize>() {}
assert_not_serialize::<tinyquant_io::CompressedVectorView<'_>>();

Fields§

§format_version: u8

Format version byte from the Level-1 header.

§config_hash: &'a str

Config hash string borrowed from the Level-1 header.

§dimension: u32

Number of dimensions.

§bit_width: u8

Bit width (2, 4, or 8).

§packed_indices: &'a [u8]

Packed index bytes (LSB-first).

§residual: Option<&'a [u8]>

Residual bytes (2 bytes per dimension), or None.

Implementations§

Source§

impl<'a> CompressedVectorView<'a>

Source

pub fn parse(data: &'a [u8]) -> Result<(Self, &'a [u8]), IoError>

Parse a single Level-1 record from the start of data.

Returns (view, unconsumed_tail).

§Errors

Returns IoError if the data is truncated, has an unknown version, an invalid bit-width, or a bad residual flag.

Source

pub fn unpack_into(&self, out: &mut [u8]) -> Result<(), IoError>

Unpack indices into caller-provided buffer (no allocation).

§Errors

Returns IoError::LengthMismatch if out.len() != self.dimension as usize.

Source

pub fn to_owned_cv(&self) -> Result<CompressedVector, IoError>

Allocating escape hatch — copies borrowed bytes into an owned CompressedVector.

§Errors

Returns IoError if unpacking or construction fails.

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

Source§

type Output = T

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