pub struct ContextKey<V: SensorVocabulary<N>, const N: usize> {
pub vocabulary: V,
}Expand description
Composite context key — generic over sensor vocabulary.
Wraps any SensorVocabulary implementation and adds:
- Deterministic
context_hash_u32()for HashMap keying cosine_similarity()for graph edge weights
Patent Claims 1 and 8.
Fields§
§vocabulary: VThe sensor vocabulary snapshot for this context.
Implementations§
Source§impl<V: SensorVocabulary<N>, const N: usize> ContextKey<V, N>
impl<V: SensorVocabulary<N>, const N: usize> ContextKey<V, N>
Sourcepub fn context_hash_u32(&self) -> u32
pub fn context_hash_u32(&self) -> u32
Deterministic FNV-1a hash of the feature vector.
Used to key context entries in fixed-size arrays (no_std compatible). Deterministic: same vocabulary produces the same hash across restarts.
Sourcepub fn cosine_similarity(&self, other: &Self) -> f32
pub fn cosine_similarity(&self, other: &Self) -> f32
Cosine similarity between two context keys via their feature vectors.
Returns a value in [0.0, 1.0] (assumes non-negative feature vectors). Used as the raw edge weight in the World Shape graph (Graph A).
Trait Implementations§
Source§impl<V: Clone + SensorVocabulary<N>, const N: usize> Clone for ContextKey<V, N>
impl<V: Clone + SensorVocabulary<N>, const N: usize> Clone for ContextKey<V, N>
Source§fn clone(&self) -> ContextKey<V, N>
fn clone(&self) -> ContextKey<V, N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V: Debug + SensorVocabulary<N>, const N: usize> Debug for ContextKey<V, N>
impl<V: Debug + SensorVocabulary<N>, const N: usize> Debug for ContextKey<V, N>
Source§impl<V: Hash + SensorVocabulary<N>, const N: usize> Hash for ContextKey<V, N>
impl<V: Hash + SensorVocabulary<N>, const N: usize> Hash for ContextKey<V, N>
Source§impl<V: PartialEq + SensorVocabulary<N>, const N: usize> PartialEq for ContextKey<V, N>
impl<V: PartialEq + SensorVocabulary<N>, const N: usize> PartialEq for ContextKey<V, N>
impl<V: Eq + SensorVocabulary<N>, const N: usize> Eq for ContextKey<V, N>
impl<V: SensorVocabulary<N>, const N: usize> StructuralPartialEq for ContextKey<V, N>
Auto Trait Implementations§
impl<V, const N: usize> Freeze for ContextKey<V, N>where
V: Freeze,
impl<V, const N: usize> RefUnwindSafe for ContextKey<V, N>where
V: RefUnwindSafe,
impl<V, const N: usize> Send for ContextKey<V, N>where
V: Send,
impl<V, const N: usize> Sync for ContextKey<V, N>where
V: Sync,
impl<V, const N: usize> Unpin for ContextKey<V, N>where
V: Unpin,
impl<V, const N: usize> UnsafeUnpin for ContextKey<V, N>where
V: UnsafeUnpin,
impl<V, const N: usize> UnwindSafe for ContextKey<V, N>where
V: UnwindSafe,
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