Skip to main content

AsyncQuery

Struct AsyncQuery 

Source
pub struct AsyncQuery<T> { /* private fields */ }
Available on crate feature async only.
Expand description

Async-facing query builder. See crate::Query for the surface semantics; this wrapper only changes the terminal methods to async fn and adds Send to every stored closure.

Implementations§

Source§

impl<T> AsyncQuery<T>
where T: Document + Send + 'static,

Source

pub fn filter<F>(self, predicate: F) -> Self
where F: Fn(&T) -> bool + Send + 'static,

Append a filter predicate. Async sibling of crate::Query::filter — adds a Send bound so the closure can ride the blocking-task hop.

Source

pub fn limit(self, n: usize) -> Self

Cap the result set at n. See crate::Query::limit.

Source

pub fn index_range<R>(self, name: &str, range: R) -> Self
where R: RangeBounds<Dynamic>,

Switch the source to a named index’s range. See crate::Query::index_range.

§Errors

As crate::Query::index_range — note that the underlying encoder fires at fetch / count time rather than here, because the async builder stores the structured Dynamic bounds and forwards them onto the blocking Query inside the blocking task.

Source

pub fn sort_by<F>(self, key: F) -> Self
where F: Fn(&T) -> Dynamic + Send + 'static,

Sort the result by key’s output. See crate::Query::sort_by. Adds a Send bound to the closure so it can ride the blocking-task hop.

Source

pub fn sort_by_bytes<F>(self, key: F) -> Self
where F: Fn(&T) -> Vec<u8> + Send + 'static,

Sort by raw bytes. See crate::Query::sort_by_bytes.

Source

pub fn sort_buffer_limit(self, n: usize) -> Self

Override the per-query sort-buffer ceiling. See crate::Query::sort_buffer_limit.

Source

pub async fn fetch(self) -> Result<Vec<T>>

Materialise the matching documents. See crate::Query::fetch.

§Errors

As crate::Query::fetch.

Source

pub async fn count(self) -> Result<u64>

Count matching documents. See crate::Query::count.

Takes self by value rather than by reference because the async-builder’s stored closures are !Sync in the general case; consuming the builder avoids cloning the closures and keeps the surface honest about ownership.

§Errors

As crate::Query::count.

Trait Implementations§

Source§

impl<T> Debug for AsyncQuery<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AsyncQuery<T>

§

impl<T> !RefUnwindSafe for AsyncQuery<T>

§

impl<T> Send for AsyncQuery<T>

§

impl<T> !Sync for AsyncQuery<T>

§

impl<T> Unpin for AsyncQuery<T>

§

impl<T> UnsafeUnpin for AsyncQuery<T>

§

impl<T> !UnwindSafe for AsyncQuery<T>

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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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