pub struct EmbeddingsBundle {
pub embeddings: Vec<BundledEmbedding>,
pub metadata: BundleMetadata,
pub category_index: HashMap<String, Vec<usize>>,
}Expand description
Bundle of pre-computed attack embeddings
Fields§
§embeddings: Vec<BundledEmbedding>Pre-computed attack embeddings
metadata: BundleMetadataMetadata about the bundle
category_index: HashMap<String, Vec<usize>>Index for fast category lookup
Implementations§
Source§impl EmbeddingsBundle
impl EmbeddingsBundle
Sourcepub fn add_embedding(&mut self, embedding: BundledEmbedding)
pub fn add_embedding(&mut self, embedding: BundledEmbedding)
Add an embedding to the bundle
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, BundleError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, BundleError>
Deserialize from bincode bytes
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), BundleError>
pub fn save_to_file(&self, path: &Path) -> Result<(), BundleError>
Save to file
Sourcepub fn load_from_file(path: &Path) -> Result<Self, BundleError>
pub fn load_from_file(path: &Path) -> Result<Self, BundleError>
Load from file
Sourcepub fn save_to_json(&self, path: &Path) -> Result<(), BundleError>
pub fn save_to_json(&self, path: &Path) -> Result<(), BundleError>
Save as JSON (human-readable)
Sourcepub fn bundled() -> Result<Self, BundleError>
pub fn bundled() -> Result<Self, BundleError>
Load bundled embeddings (embedded in binary)
This loads the pre-computed embeddings that are embedded in the library at compile time. Returns an empty bundle if no bundled data is available.
Note: Bundled embeddings are primarily used with oxide-guard-pro SemanticSimilarityGuard. Returns an empty bundle by default.
Sourcepub fn has_bundled() -> bool
pub fn has_bundled() -> bool
Check if bundled embeddings are available
Sourcepub fn by_category(&self, category: &str) -> Vec<&BundledEmbedding>
pub fn by_category(&self, category: &str) -> Vec<&BundledEmbedding>
Get embeddings by category
Sourcepub fn all(&self) -> &[BundledEmbedding]
pub fn all(&self) -> &[BundledEmbedding]
Get all embeddings
Trait Implementations§
Source§impl Clone for EmbeddingsBundle
impl Clone for EmbeddingsBundle
Source§fn clone(&self) -> EmbeddingsBundle
fn clone(&self) -> EmbeddingsBundle
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<'de> Deserialize<'de> for EmbeddingsBundle
impl<'de> Deserialize<'de> for EmbeddingsBundle
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 EmbeddingsBundle
impl RefUnwindSafe for EmbeddingsBundle
impl Send for EmbeddingsBundle
impl Sync for EmbeddingsBundle
impl Unpin for EmbeddingsBundle
impl UnwindSafe for EmbeddingsBundle
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