pub struct Codebook {
pub version: u32,
pub dimensionality: usize,
pub basis_vectors: Vec<BasisVector>,
pub semantic_markers: Vec<SparseVec>,
pub statistics: CodebookStatistics,
pub salt: Option<[u8; 32]>,
}Expand description
The Codebook - acts as the private key for reconstruction
Fields§
§version: u32Version for compatibility
dimensionality: usizeDimensionality of basis vectors
basis_vectors: Vec<BasisVector>The basis vectors forming the encoding dictionary Data is projected onto these bases
semantic_markers: Vec<SparseVec>Semantic marker vectors for outlier detection
statistics: CodebookStatisticsStatistics for adaptive encoding
salt: Option<[u8; 32]>Cryptographic salt for key derivation (optional)
Implementations§
Source§impl Codebook
impl Codebook
Sourcepub fn with_salt(dimensionality: usize, salt: [u8; 32]) -> Self
pub fn with_salt(dimensionality: usize, salt: [u8; 32]) -> Self
Create a codebook with cryptographic salt for key derivation
Sourcepub fn initialize_standard_basis(&mut self)
pub fn initialize_standard_basis(&mut self)
Initialize with common basis vectors for text/binary data
Sourcepub fn project(&self, data: &[u8]) -> ProjectionResult
pub fn project(&self, data: &[u8]) -> ProjectionResult
Project data onto the codebook basis Returns coefficients, residual, and detected outliers
Sourcepub fn project_with_config(
&self,
data: &[u8],
config: &ProjectionConfig,
) -> ProjectionResult
pub fn project_with_config( &self, data: &[u8], config: &ProjectionConfig, ) -> ProjectionResult
Project data onto the codebook using custom configuration
Sourcepub fn reconstruct(
&self,
projection: &ProjectionResult,
expected_size: usize,
) -> Vec<u8> ⓘ
pub fn reconstruct( &self, projection: &ProjectionResult, expected_size: usize, ) -> Vec<u8> ⓘ
Reconstruct original data from projection result
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Codebook
impl<'de> Deserialize<'de> for Codebook
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Codebook
impl RefUnwindSafe for Codebook
impl Send for Codebook
impl Sync for Codebook
impl Unpin for Codebook
impl UnwindSafe for Codebook
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
Mutably borrows from an owned value. Read more