pub trait Provide<L: Lt = ()>: Sized {
// Required method
fn provide(self, query: &mut Query<'_, L>) -> Option<Self>;
// Provided methods
fn request<Tag: TagFor<L>>(
self,
arg: Tag::ArgValue,
) -> Result<Tag::Value, Self> { ... }
fn request_value<T: 'static>(self) -> Result<T, Self> { ... }
fn request_ref<'x, T: 'static + ?Sized>(self) -> Result<&'x T, Self>
where Ref<Value<T>>: TagFor<L, ArgValue = (), Value = &'x T> { ... }
fn request_mut<'x, T: 'static + ?Sized>(self) -> Result<&'x mut T, Self>
where Mut<Value<T>>: TagFor<L, ArgValue = (), Value = &'x mut T> { ... }
}Expand description
Provides access to values of arbitrary type.
Requested values are specified using a ResourceTag implementation, or to be more specific, a TagFor<L>
implementation.
Required Methods§
Provided Methods§
Sourcefn request<Tag: TagFor<L>>(self, arg: Tag::ArgValue) -> Result<Tag::Value, Self>
fn request<Tag: TagFor<L>>(self, arg: Tag::ArgValue) -> Result<Tag::Value, Self>
Requests the value specified by Tag. Returns Err(self) if the value was not available.
arg should contain whatever data is needed to request the tagged type.
If no arguments are necessary, this will usually be the unit type ().
Sourcefn request_value<T: 'static>(self) -> Result<T, Self>
fn request_value<T: 'static>(self) -> Result<T, Self>
Requests a value of type T, marked by the tag Value<T>.
Values of type T must not hold any borrowed data.
Sourcefn request_ref<'x, T: 'static + ?Sized>(self) -> Result<&'x T, Self>
fn request_ref<'x, T: 'static + ?Sized>(self) -> Result<&'x T, Self>
Requests a shared reference to a value of type T, marked by the tag Ref<Value<T>>.
Values of type T must not hold any borrowed data.
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<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + 'data>
Available on crate feature alloc only.
impl<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + 'data>
alloc only.Source§impl<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + Send + 'data>
Available on crate feature alloc only.
impl<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + Send + 'data>
alloc only.Source§impl<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + Send + Sync + 'data>
Available on crate feature alloc only.
impl<'data, L: Lt + 'data> Provide<L> for Box<dyn ProvideBox<L> + Send + Sync + 'data>
alloc only.