Struct async_graphql::dataloader::DataLoader[][src]

pub struct DataLoader<T, C = NoCache> { /* fields omitted */ }
This is supported on crate feature dataloader only.
Expand description

Implementations

impl<T> DataLoader<T, NoCache>[src]

pub fn new(loader: T) -> Self[src]

Use Loader to create a DataLoader that does not cache records.

impl<T, C: CacheFactory> DataLoader<T, C>[src]

pub fn with_cache(loader: T, cache_factory: C) -> Self[src]

Use Loader to create a DataLoader with a cache factory.

pub fn delay(self, delay: Duration) -> Self[src]

Specify the delay time for loading data, the default is 1ms.

pub fn max_batch_size(self, max_batch_size: usize) -> Self[src]

pub fn Specify the max batch size for loading data, the default is 1000.

If the keys waiting to be loaded reach the threshold, they are loaded immediately.

pub fn loader(&self) -> &T[src]

Get the loader.

pub async fn load_one<K>(&self, key: K) -> Result<Option<T::Value>, T::Error> where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Use this DataLoader load a data.

pub async fn load_many<K, I>(
    &self,
    keys: I
) -> Result<HashMap<K, T::Value>, T::Error> where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    I: IntoIterator<Item = K>,
    T: Loader<K>, 
[src]

Use this DataLoader to load some data.

pub async fn feed_many<K, I>(&self, values: I) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    I: IntoIterator<Item = (K, T::Value)>,
    T: Loader<K>, 
[src]

Feed some data into the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

pub async fn feed_one<K>(&self, key: K, value: T::Value) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Feed some data into the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

pub fn clear<K>(&self) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Clears the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

Auto Trait Implementations

impl<T, C> RefUnwindSafe for DataLoader<T, C> where
    C: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, C> Send for DataLoader<T, C> where
    C: Send,
    T: Send

impl<T, C> Sync for DataLoader<T, C> where
    C: Sync,
    T: Sync

impl<T, C> Unpin for DataLoader<T, C> where
    C: Unpin,
    T: Unpin

impl<T, C> UnwindSafe for DataLoader<T, C> where
    C: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> FutureExt for T[src]

fn with_context(self, otel_cx: Context) -> WithContext<Self>[src]

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

fn with_current_context(self) -> WithContext<Self>[src]

Attaches the current Context to this type, returning a WithContext wrapper. Read more

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> WithSubscriber for T[src]

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>, 
[src]

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

fn with_current_subscriber(self) -> WithDispatch<Self>[src]

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more