VectorStore

Struct VectorStore 

Source
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>

Source

pub const fn new(engine: E) -> Self

Create a new vector store with the given storage engine.

Source

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.

Source

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.

Source

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.

Source

pub fn list_spaces(&self) -> Result<Vec<EmbeddingSpace>, VectorError>

List all embedding spaces.

§Errors

Returns an error if the storage operation fails.

Source

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
Source

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
Source

pub fn delete( &self, entity_id: EntityId, space_name: &EmbeddingName, ) -> Result<bool, VectorError>

Delete an embedding for an entity from a space.

§Returns

Returns Ok(true) if the embedding was deleted, Ok(false) if it didn’t exist.

§Errors

Returns an error if the storage operation fails.

Source

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.

Source

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.

Source

pub fn count(&self, space_name: &EmbeddingName) -> Result<usize, VectorError>

Count the number of embeddings in a space.

§Errors

Returns an error if the storage operation fails.

Source

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.

Source

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
Source

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.

Auto Trait Implementations§

§

impl<E> Freeze for VectorStore<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for VectorStore<E>
where E: RefUnwindSafe,

§

impl<E> Send for VectorStore<E>

§

impl<E> Sync for VectorStore<E>

§

impl<E> Unpin for VectorStore<E>
where E: Unpin,

§

impl<E> UnwindSafe for VectorStore<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more