InternalLoader

Trait InternalLoader 

Source
pub trait InternalLoader<M> {
    type Item;
    type Query;
    type Error: Debug + 'static;

    const CHUNK_SIZE: Option<usize> = None;

    // Required method
    fn load_items_inner(
        &self,
        range: Range<usize>,
        query: &Self::Query,
    ) -> impl Future<Output = Result<LoadedItems<Self::Item>, Self::Error>>;

    // Provided methods
    fn load_items(
        &self,
        range: Range<usize>,
        query: &Self::Query,
    ) -> impl Future<Output = Result<LoadedItems<Self::Item>, Self::Error>> { ... }
    fn item_count(
        &self,
        _query: &Self::Query,
    ) -> impl Future<Output = Result<Option<usize>, Self::Error>> { ... }
}
Expand description

This is the trait for the actually used internal loaders. This trait is automatically implemented for all the user facing loader traits.

Provided Associated Constants§

Source

const CHUNK_SIZE: Option<usize> = None

If this Some(…) then the data will be loaded in chunks of this size. This is useful for paginated data sources.

Required Associated Types§

Source

type Item

The type of items that will be loaded.

Source

type Query

The type of the query data that will be used to load items.

Can be used to filter or sort the items for example.

Source

type Error: Debug + 'static

The type of errors that can occur during loading.

Required Methods§

Source

fn load_items_inner( &self, range: Range<usize>, query: &Self::Query, ) -> impl Future<Output = Result<LoadedItems<Self::Item>, Self::Error>>

Don’t call this directly. Call load_items instead.

Loads the items respecting the given range and query. This does not respect CHUNK_SIZE.

Provided Methods§

Source

fn load_items( &self, range: Range<usize>, query: &Self::Query, ) -> impl Future<Output = Result<LoadedItems<Self::Item>, Self::Error>>

Loads the items respecting the given range and query together with CHUNK_SIZE.

Source

fn item_count( &self, _query: &Self::Query, ) -> impl Future<Output = Result<Option<usize>, Self::Error>>

The total number of items of this data source.

Returns Ok(None) if unknown (which is the default).

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§