[][src]Struct modio::Query

pub struct Query<T> { /* fields omitted */ }

Interface for retrieving search results.

Implementations

impl<T: DeserializeOwned + Send> Query<T>[src]

pub async fn first(self) -> Result<Option<T>>[src]

Returns the first search result.

pub async fn first_page(self) -> Result<Vec<T>>[src]

Returns the first search result page.

pub async fn collect(self) -> Result<Vec<T>>[src]

Returns the complete search result list.

pub async fn iter(self) -> Result<impl Stream<Item = Result<T>>>[src]

Provides a stream over all search result items.

Beware that a Filter::with_limit will NOT limit the number of items returned by the stream, but limits the page size for the underlying API requests.

Example

use futures_util::TryStreamExt;
use modio::filter::prelude::*;

let filter = Fulltext::eq("soldier");
let mut st = modio.game(51).mods().search(filter).iter().await?;

// Stream of `Mod`
while let Some(mod_) = st.try_next().await? {
    println!("{}. {}", mod_.id, mod_.name);
}

use futures_util::StreamExt;

// Retrieve the first 10 mods. (Default page size is `100`.)
let filter = Fulltext::eq("tftd") + with_limit(10);
let st = modio.game(51).mods().search(filter).iter().await?;
let mut st = st.take(10);

// Stream of `Mod`
while let Some(mod_) = st.try_next().await? {
    println!("{}. {}", mod_.id, mod_.name);
}

pub async fn paged(self) -> Result<impl Stream<Item = Result<Page<T>>>>[src]

Provides a stream over all search result pages.

Example

use futures_util::TryStreamExt;
use modio::filter::prelude::*;

let filter = Fulltext::eq("tftd").limit(10);
let mut st = modio.game(51).mods().search(filter).paged().await?;

// Stream of paged results `Page<Mod>` with page size = 10
while let Some(page) = st.try_next().await? {
    println!("Page {}/{}", page.current(), page.page_count());
    for item in page {
        println!("  {}. {}", item.id, item.name);
    }
}

Auto Trait Implementations

impl<T> !RefUnwindSafe for Query<T>[src]

impl<T> Send for Query<T> where
    T: Send
[src]

impl<T> Sync for Query<T> where
    T: Sync
[src]

impl<T> Unpin for Query<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Query<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.