pub struct VectorStore<E: StorageEngine> { /* private fields */ }Expand description
A store for vector embeddings.
VectorStore provides CRUD operations for embeddings organized into named
embedding spaces. Each space defines a dimension and distance metric, and
the store validates that all embeddings match their space’s dimension.
Implementations§
Source§impl<E: StorageEngine> VectorStore<E>
impl<E: StorageEngine> VectorStore<E>
Sourcepub fn create_space(&self, space: &EmbeddingSpace) -> Result<(), VectorError>
pub fn create_space(&self, space: &EmbeddingSpace) -> Result<(), VectorError>
Create a new embedding space.
§Errors
Returns an error if the space already exists or if the storage operation fails.
Sourcepub fn get_space(
&self,
name: &EmbeddingName,
) -> Result<EmbeddingSpace, VectorError>
pub fn get_space( &self, name: &EmbeddingName, ) -> Result<EmbeddingSpace, VectorError>
Get an embedding space by name.
§Errors
Returns an error if the space doesn’t exist or if the storage operation fails.
Sourcepub fn delete_space(&self, name: &EmbeddingName) -> Result<(), VectorError>
pub fn delete_space(&self, name: &EmbeddingName) -> Result<(), VectorError>
Delete an embedding space and all its embeddings.
§Errors
Returns an error if the space doesn’t exist or if the storage operation fails.
Sourcepub fn list_spaces(&self) -> Result<Vec<EmbeddingSpace>, VectorError>
pub fn list_spaces(&self) -> Result<Vec<EmbeddingSpace>, VectorError>
Sourcepub fn put(
&self,
entity_id: EntityId,
space_name: &EmbeddingName,
embedding: &Embedding,
) -> Result<(), VectorError>
pub fn put( &self, entity_id: EntityId, space_name: &EmbeddingName, embedding: &Embedding, ) -> Result<(), VectorError>
Store an embedding for an entity in a space.
§Errors
Returns an error if:
- The embedding space doesn’t exist
- The embedding dimension doesn’t match the space dimension
- The storage operation fails
Sourcepub fn get(
&self,
entity_id: EntityId,
space_name: &EmbeddingName,
) -> Result<Embedding, VectorError>
pub fn get( &self, entity_id: EntityId, space_name: &EmbeddingName, ) -> Result<Embedding, VectorError>
Get an embedding for an entity from a space.
§Errors
Returns an error if:
- The embedding space doesn’t exist
- The embedding doesn’t exist for this entity
- The storage operation fails
Sourcepub fn delete(
&self,
entity_id: EntityId,
space_name: &EmbeddingName,
) -> Result<bool, VectorError>
pub fn delete( &self, entity_id: EntityId, space_name: &EmbeddingName, ) -> Result<bool, VectorError>
Sourcepub fn exists(
&self,
entity_id: EntityId,
space_name: &EmbeddingName,
) -> Result<bool, VectorError>
pub fn exists( &self, entity_id: EntityId, space_name: &EmbeddingName, ) -> Result<bool, VectorError>
Check if an embedding exists for an entity in a space.
§Errors
Returns an error if the storage operation fails.
Sourcepub fn list_entities(
&self,
space_name: &EmbeddingName,
) -> Result<Vec<EntityId>, VectorError>
pub fn list_entities( &self, space_name: &EmbeddingName, ) -> Result<Vec<EntityId>, VectorError>
List all entity IDs that have embeddings in a space.
§Errors
Returns an error if the storage operation fails.
Sourcepub fn count(&self, space_name: &EmbeddingName) -> Result<usize, VectorError>
pub fn count(&self, space_name: &EmbeddingName) -> Result<usize, VectorError>
Sourcepub fn get_many(
&self,
entity_ids: &[EntityId],
space_name: &EmbeddingName,
) -> Result<Vec<(EntityId, Option<Embedding>)>, VectorError>
pub fn get_many( &self, entity_ids: &[EntityId], space_name: &EmbeddingName, ) -> Result<Vec<(EntityId, Option<Embedding>)>, VectorError>
Get multiple embeddings at once.
Returns a vector of (EntityId, Option<Embedding>) tuples.
If an embedding doesn’t exist for an entity, the option is None.
§Errors
Returns an error if the storage operation fails.
Sourcepub fn put_many(
&self,
embeddings: &[(EntityId, Embedding)],
space_name: &EmbeddingName,
) -> Result<(), VectorError>
pub fn put_many( &self, embeddings: &[(EntityId, Embedding)], space_name: &EmbeddingName, ) -> Result<(), VectorError>
Store multiple embeddings at once.
All embeddings must match the space’s dimension.
§Errors
Returns an error if:
- The embedding space doesn’t exist
- Any embedding dimension doesn’t match the space dimension
- The storage operation fails
Sourcepub fn delete_entity(&self, entity_id: EntityId) -> Result<usize, VectorError>
pub fn delete_entity(&self, entity_id: EntityId) -> Result<usize, VectorError>
Delete all embeddings for an entity across all spaces.
§Errors
Returns an error if the storage operation fails.