Paginated

Trait Paginated 

Source
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§

Source

type Params: Unpin

The type of parameters used to request a page (e.g., page number, cursor, offset).

Source

type Item: Unpin

The type of item that the stream will yield.

Source

type Error

The type of error that can occur during page fetching.

Required Methods§

Source

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 Vec of items for the current page.
    • An Option for the next page’s parameters. Some(next_params) indicates there might be more data, and None signifies the end of the data source.
  • 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.

Implementors§