pub trait Paginated {
type Params: Unpin;
type Item: Unpin;
type Error;
// Required method
fn fetch_page(
&self,
params: Self::Params,
) -> impl Future<Output = Result<(Vec<Self::Item>, Option<Self::Params>), Self::Error>> + Send + 'static;
}Expand description
Represents a data source that can be paginated.
Required Associated Types§
Required Methods§
Sourcefn fetch_page(
&self,
params: Self::Params,
) -> impl Future<Output = Result<(Vec<Self::Item>, Option<Self::Params>), Self::Error>> + Send + 'static
fn fetch_page( &self, params: Self::Params, ) -> impl Future<Output = Result<(Vec<Self::Item>, Option<Self::Params>), Self::Error>> + Send + 'static
Asynchronously fetches a single page of items.
This method takes the current params and should return a Result containing:
Ok((Vec<Self::Item>, Option<Self::Params>)):- A
Vecof items for the current page. - An
Optionfor the next page’s parameters.Some(next_params)indicates there might be more data, andNonesignifies the end of the data source.
- A
Err(Self::Error): If an error occurs during fetching.
The returned Future must be Send + 'static.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.