Struct Request

Source
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>

Source

pub fn provide_value<T>(&mut self, value: T) -> &mut Self
where T: 'static,

Provide a value or other type with only static lifetimes.

Source

pub fn provide_value_with<T>(&mut self, fulfil: impl FnOnce() -> T) -> &mut Self
where T: 'static,

Provide a value or other type with only static lifetimes computed using a closure.

Source

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.

Source

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.

Source

pub fn would_be_satisfied_by_value_of<T>(&self) -> bool
where 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.

Source

pub fn would_be_satisfied_by_ref_of<T>(&self) -> bool
where 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.

Auto Trait Implementations§

§

impl<'a> !Freeze for Request<'a>

§

impl<'a> !RefUnwindSafe for Request<'a>

§

impl<'a> !Send for Request<'a>

§

impl<'a> !Sized for Request<'a>

§

impl<'a> !Sync for Request<'a>

§

impl<'a> !Unpin for Request<'a>

§

impl<'a> !UnwindSafe for Request<'a>

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