pub struct VectorLiteClient { /* private fields */ }Expand description
Main client for interacting with VectorLite
The VectorLiteClient provides a high-level interface for managing vector collections,
performing searches, and handling embeddings. It’s designed to be thread-safe and
efficient for AI agent workloads.
§Thread Safety
The client uses Arc<RwLock<>> for collections and atomic counters for ID generation,
making it safe to use across multiple threads.
§Examples
use vectorlite::{VectorLiteClient, EmbeddingGenerator, IndexType};
let mut client = VectorLiteClient::new(Box::new(EmbeddingGenerator::new()?));
client.create_collection("docs", IndexType::HNSW)?;Implementations§
Source§impl VectorLiteClient
impl VectorLiteClient
pub fn new(embedding_function: Box<dyn EmbeddingFunction>) -> Self
pub fn create_collection( &mut self, name: &str, index_type: IndexType, ) -> VectorLiteResult<()>
pub fn get_collection(&self, name: &str) -> Option<&Arc<Collection>>
pub fn list_collections(&self) -> Vec<String>
pub fn delete_collection(&mut self, name: &str) -> VectorLiteResult<()>
pub fn has_collection(&self, name: &str) -> bool
pub fn add_text_to_collection( &self, collection_name: &str, text: &str, metadata: Option<Value>, ) -> VectorLiteResult<u64>
pub fn search_text_in_collection( &self, collection_name: &str, query_text: &str, k: usize, similarity_metric: SimilarityMetric, ) -> VectorLiteResult<Vec<SearchResult>>
pub fn delete_from_collection( &self, collection_name: &str, id: u64, ) -> VectorLiteResult<()>
pub fn get_vector_from_collection( &self, collection_name: &str, id: u64, ) -> VectorLiteResult<Option<Vector>>
pub fn get_collection_info( &self, collection_name: &str, ) -> VectorLiteResult<CollectionInfo>
Sourcepub fn add_collection(&mut self, collection: Collection) -> VectorLiteResult<()>
pub fn add_collection(&mut self, collection: Collection) -> VectorLiteResult<()>
Add a collection directly (used for loading from files)
Auto Trait Implementations§
impl Freeze for VectorLiteClient
impl !RefUnwindSafe for VectorLiteClient
impl Send for VectorLiteClient
impl Sync for VectorLiteClient
impl Unpin for VectorLiteClient
impl !UnwindSafe for VectorLiteClient
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more