Struct Cached

Source
pub struct Cached<'cx, S, P>
where S: Service, P: Provider<'cx, S>,
{ /* private fields */ }
Expand description

Cached provider

A provider that calls the underlying provider on the first call and returns the result of that on all calls

Implementations§

Source§

impl<'cx, S, P> Cached<'cx, S, P>
where S: Service, P: Provider<'cx, S>,

Source

pub fn new(provider: P) -> Self

Create a new cached provider

Source§

impl<'cx, S, F> Cached<'cx, S, F>
where S: Service, F: Fn(&'cx Context<'_>, S::Argument<'_>) -> S::Output<'cx> + Send + Sync + 'cx,

Source

pub fn new_fn(provider: F) -> Self

Equivelant to calling Cached::new with a provider wrapped in a provider_fn type hint

Trait Implementations§

Source§

impl<'cx, S, P> Default for Cached<'cx, S, P>
where S: Service, P: Provider<'cx, S> + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'cx, S, P> Provider<'cx, &'static S> for Cached<'cx, S, P>
where S: Service, S::Output<'cx>: Send + Sync, P: Provider<'cx, S>,

Source§

fn provide( &'cx self, cx: &'cx Context<'_>, arg: S::Argument<'_>, ) -> &'cx S::Output<'cx>

Build the output object

Auto Trait Implementations§

§

impl<'cx, S, P> !Freeze for Cached<'cx, S, P>

§

impl<'cx, S, P> RefUnwindSafe for Cached<'cx, S, P>

§

impl<'cx, S, P> Send for Cached<'cx, S, P>
where <S as Service>::Output<'cx>: Send,

§

impl<'cx, S, P> Sync for Cached<'cx, S, P>
where <S as Service>::Output<'cx>: Sync + Send,

§

impl<'cx, S, P> Unpin for Cached<'cx, S, P>
where P: Unpin, <S as Service>::Output<'cx>: Unpin,

§

impl<'cx, S, P> UnwindSafe for Cached<'cx, S, P>
where P: UnwindSafe, <S as Service>::Output<'cx>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.