pub struct CustomStrategy<Q> { /* private fields */ }
Expand description
Implements the strategy pattern for vector similarity search, allowing retrieval backends to define custom query generation logic through closures.
Implementations§
Source§impl<Q: Send + Sync + 'static> CustomStrategy<Q>
impl<Q: Send + Sync + 'static> CustomStrategy<Q>
Sourcepub fn from_query(
query: impl Fn(&Query<Pending>) -> Result<Q> + Send + Sync + 'static,
) -> Self
pub fn from_query( query: impl Fn(&Query<Pending>) -> Result<Q> + Send + Sync + 'static, ) -> Self
Creates a new strategy with a synchronous query generator.
Sourcepub fn from_async_query<F>(
query: impl Fn(&Query<Pending>) -> F + Send + Sync + 'static,
) -> Self
pub fn from_async_query<F>( query: impl Fn(&Query<Pending>) -> F + Send + Sync + 'static, ) -> Self
Creates a new strategy with an asynchronous query generator.
Sourcepub async fn build_query(&self, query_node: &Query<Pending>) -> Result<Q>
pub async fn build_query(&self, query_node: &Query<Pending>) -> Result<Q>
Generates a query using either the sync or async generator. Returns error if no query generator is set.
§Errors
Returns an error if:
- No query generator has been configured
- The configured query generator fails during query generation
Trait Implementations§
Source§impl<Q> Clone for CustomStrategy<Q>
impl<Q> Clone for CustomStrategy<Q>
Source§impl<Q> Default for CustomStrategy<Q>
impl<Q> Default for CustomStrategy<Q>
impl<Q: Send + Sync + 'static> SearchStrategy for CustomStrategy<Q>
Auto Trait Implementations§
impl<Q> Freeze for CustomStrategy<Q>
impl<Q> !RefUnwindSafe for CustomStrategy<Q>
impl<Q> Send for CustomStrategy<Q>where
Q: Send,
impl<Q> Sync for CustomStrategy<Q>where
Q: Sync,
impl<Q> Unpin for CustomStrategy<Q>where
Q: Unpin,
impl<Q> !UnwindSafe for CustomStrategy<Q>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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