Trait dataload_rs::BatchFunction[][src]

pub trait BatchFunction<K, V> {
    type Context;
#[must_use]    fn load<'life0, 'life1, 'async_trait>(
        keys: &'life0 [K],
        context: &'life1 Self::Context
    ) -> Pin<Box<dyn Future<Output = Vec<(K, V)>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }

A BatchFunction defines the method through which some Loader may fetch batched data from some resource. The BatchFunction receives a slice of keys that have been requested during the Loader’s most recent execution frame, and some user defined context struct.

Unlike the reference facebook dataloader implementation, the BatchFunction is not required to return a result for all keys that were provided. Instead, it can return any set of loaded key value pairs, in any order it chooses. Requesters of keys whose values are not returned by the BatchFunction will receive a None. Error handling and reporting is expected to be done within the BatchFunction (i.e. through some error sink in the context).

Multiple BatchFunctions (and therefore loaders) can share the same context (likely through an Arc).

Associated Types

Loading content...

Required methods

#[must_use]fn load<'life0, 'life1, 'async_trait>(
    keys: &'life0 [K],
    context: &'life1 Self::Context
) -> Pin<Box<dyn Future<Output = Vec<(K, V)>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Loading content...

Implementors

Loading content...