pub struct Request<'a>(/* private fields */);
Expand description
Request
supports generic, type-driven access to data.
This type is based on the unstable request type in std::error
and it
works in pretty much the exact same way.
Implementations§
Source§impl<'a> Request<'a>
impl<'a> Request<'a>
Sourcepub fn provide_value<T>(&mut self, value: T) -> &mut Selfwhere
T: 'static,
pub fn provide_value<T>(&mut self, value: T) -> &mut Selfwhere
T: 'static,
Provide a value or other type with only static lifetimes.
Sourcepub fn provide_value_with<T>(&mut self, fulfil: impl FnOnce() -> T) -> &mut Selfwhere
T: 'static,
pub fn provide_value_with<T>(&mut self, fulfil: impl FnOnce() -> T) -> &mut Selfwhere
T: 'static,
Provide a value or other type with only static lifetimes computed using a closure.
Sourcepub fn provide_ref<T: ?Sized + 'static>(&mut self, value: &'a T) -> &mut Self
pub fn provide_ref<T: ?Sized + 'static>(&mut self, value: &'a T) -> &mut Self
Provide a reference. The referee type must be bounded by 'static
,
but may be unsized.
Sourcepub fn provide_ref_with<T: ?Sized + 'static>(
&mut self,
fulfil: impl FnOnce() -> &'a T,
) -> &mut Self
pub fn provide_ref_with<T: ?Sized + 'static>( &mut self, fulfil: impl FnOnce() -> &'a T, ) -> &mut Self
Provide a reference computed using a closure. The referee type
must be bounded by 'static
, but may be unsized.
Sourcepub fn would_be_satisfied_by_value_of<T>(&self) -> boolwhere
T: 'static,
pub fn would_be_satisfied_by_value_of<T>(&self) -> boolwhere
T: 'static,
Check if the Request
would be satisfied if provided with a
value of the specified type. If the type does not match or has
already been provided, returns false.
Sourcepub fn would_be_satisfied_by_ref_of<T>(&self) -> boolwhere
T: ?Sized + 'static,
pub fn would_be_satisfied_by_ref_of<T>(&self) -> boolwhere
T: ?Sized + 'static,
Check if the Request
would be satisfied if provided with a
reference to a value of the specified type. If the type does
not match or has already been provided, returns false.