Trait DataLoader

Source
pub trait DataLoader {
    type Key;
    type Value;
    type Error;

    // Required methods
    fn load(
        &self,
        key: Self::Key,
    ) -> impl Future<Output = Result<Option<Self::Value>, Self::Error>>;
    fn load_many(
        &self,
        keys: impl IntoIterator<Item = Self::Key> + Send,
    ) -> impl Future<Output = Result<HashMap<Self::Key, Self::Value>, Self::Error>>;
}

Required Associated Types§

Required Methods§

Source

fn load( &self, key: Self::Key, ) -> impl Future<Output = Result<Option<Self::Value>, Self::Error>>

Source

fn load_many( &self, keys: impl IntoIterator<Item = Self::Key> + Send, ) -> impl Future<Output = Result<HashMap<Self::Key, Self::Value>, Self::Error>>

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.

Implementations on Foreign Types§

Source§

impl<E> DataLoader for DataLoader<E>
where E: DataLoaderFetcher + Send + Sync + 'static,

Source§

type Error = ()

Source§

type Key = <E as DataLoaderFetcher>::Key

Source§

type Value = <E as DataLoaderFetcher>::Value

Source§

async fn load(&self, key: Self::Key) -> Result<Option<Self::Value>, Self::Error>

Source§

async fn load_many( &self, keys: impl IntoIterator<Item = Self::Key> + Send, ) -> Result<HashMap<Self::Key, Self::Value>, Self::Error>

Implementors§