pub struct VectorDB { /* private fields */ }Expand description
Main VectorDB class for browser usage
Implementations§
Source§impl VectorDB
impl VectorDB
Sourcepub fn new(
dimensions: usize,
metric: Option<String>,
use_hnsw: Option<bool>,
) -> Result<VectorDB, JsValue>
pub fn new( dimensions: usize, metric: Option<String>, use_hnsw: Option<bool>, ) -> Result<VectorDB, JsValue>
Create a new VectorDB instance
§Arguments
dimensions- Vector dimensionsmetric- Distance metric (“euclidean”, “cosine”, “dotproduct”, “manhattan”)use_hnsw- Whether to use HNSW index for faster search
Sourcepub fn insert(
&self,
vector: Float32Array,
id: Option<String>,
metadata: Option<JsValue>,
) -> Result<String, JsValue>
pub fn insert( &self, vector: Float32Array, id: Option<String>, metadata: Option<JsValue>, ) -> Result<String, JsValue>
Sourcepub fn search(
&self,
query: Float32Array,
k: usize,
filter: Option<JsValue>,
) -> Result<Vec<JsSearchResult>, JsValue>
pub fn search( &self, query: Float32Array, k: usize, filter: Option<JsValue>, ) -> Result<Vec<JsSearchResult>, JsValue>
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Get database dimensions
Sourcepub fn save_to_indexed_db(&self) -> Result<Promise, JsValue>
pub fn save_to_indexed_db(&self) -> Result<Promise, JsValue>
Save database to IndexedDB Returns a Promise that resolves when save is complete
Trait Implementations§
Source§impl FromWasmAbi for VectorDB
impl FromWasmAbi for VectorDB
Source§impl IntoWasmAbi for VectorDB
impl IntoWasmAbi for VectorDB
Source§impl LongRefFromWasmAbi for VectorDB
impl LongRefFromWasmAbi for VectorDB
Source§impl OptionFromWasmAbi for VectorDB
impl OptionFromWasmAbi for VectorDB
Source§impl OptionIntoWasmAbi for VectorDB
impl OptionIntoWasmAbi for VectorDB
Source§impl RefFromWasmAbi for VectorDB
impl RefFromWasmAbi for VectorDB
Source§impl RefMutFromWasmAbi for VectorDB
impl RefMutFromWasmAbi for VectorDB
Source§impl TryFromJsValue for VectorDB
impl TryFromJsValue for VectorDB
Source§impl VectorFromWasmAbi for VectorDB
impl VectorFromWasmAbi for VectorDB
Source§impl VectorIntoWasmAbi for VectorDB
impl VectorIntoWasmAbi for VectorDB
impl SupportsConstructor for VectorDB
impl SupportsInstanceProperty for VectorDB
impl SupportsStaticProperty for VectorDB
Auto Trait Implementations§
impl Freeze for VectorDB
impl !RefUnwindSafe for VectorDB
impl Send for VectorDB
impl Sync for VectorDB
impl Unpin for VectorDB
impl !UnwindSafe for VectorDB
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.