Skip to main content

VsaBackend

Trait VsaBackend 

Source
pub trait VsaBackend {
    type Vector: Clone + Send + Sync + 'static;

    // Required methods
    fn zero(&self) -> Self::Vector;
    fn bundle(&self, a: &Self::Vector, b: &Self::Vector) -> Self::Vector;
    fn bind(&self, a: &Self::Vector, b: &Self::Vector) -> Self::Vector;
    fn cosine(&self, a: &Self::Vector, b: &Self::Vector) -> f64;
    fn encode_data(
        &self,
        data: &[u8],
        config: &ReversibleVSAConfig,
        path: Option<&str>,
    ) -> Self::Vector;
    fn decode_data(
        &self,
        vec: &Self::Vector,
        config: &ReversibleVSAConfig,
        path: Option<&str>,
        expected_size: usize,
    ) -> Vec<u8> ;
}
Expand description

Backend-agnostic VSA operations exposed to a kernel/runtime.

This is intentionally small: it captures the stable semantic contract while allowing internal representation changes (e.g., migration to ternary-native packed vectors).

Required Associated Types§

Source

type Vector: Clone + Send + Sync + 'static

Required Methods§

Source

fn zero(&self) -> Self::Vector

Source

fn bundle(&self, a: &Self::Vector, b: &Self::Vector) -> Self::Vector

Source

fn bind(&self, a: &Self::Vector, b: &Self::Vector) -> Self::Vector

Source

fn cosine(&self, a: &Self::Vector, b: &Self::Vector) -> f64

Source

fn encode_data( &self, data: &[u8], config: &ReversibleVSAConfig, path: Option<&str>, ) -> Self::Vector

Source

fn decode_data( &self, vec: &Self::Vector, config: &ReversibleVSAConfig, path: Option<&str>, expected_size: usize, ) -> Vec<u8>

Implementors§