[−][src]Struct object_provider::Request
A dynamic request for an object based on its type.
'r
is the lifetime of request, and 'out
is the lifetime of the requested
reference.
Methods
impl<'r, 'out> Request<'r, 'out>
[src]
pub fn provide<T: ?Sized + 'static>(
self,
value: &'out T
) -> ProvideResult<'r, 'out>
[src]
self,
value: &'out T
) -> ProvideResult<'r, 'out>
Provides an object of type T
in response to this request.
Returns Err(FulfilledRequest)
if the value was successfully provided,
and Ok(self)
if T
was not the type being requested.
This method can be chained within provide
implementations using the
?
operator to concisely provide multiple objects.
pub fn provide_with<T: ?Sized + 'static, F>(
self,
cb: F
) -> ProvideResult<'r, 'out> where
F: FnOnce() -> &'out T,
[src]
self,
cb: F
) -> ProvideResult<'r, 'out> where
F: FnOnce() -> &'out T,
Lazily provides an object of type T
in response to this request.
Returns Err(FulfilledRequest)
if the value was successfully provided,
and Ok(self)
if T
was not the type being requested.
The passed closure is only called if the value will be successfully provided.
This method can be chained within provide
implementations using the
?
operator to concisely provide multiple objects.
pub fn type_id(&self) -> TypeId
[src]
Get the TypeId
of the requested type.
pub fn is<T: ?Sized + 'static>(&self) -> bool
[src]
Returns true
if the requested type is the same as T
pub fn with<T: ?Sized + 'static, F>(f: F) -> Option<&'out T> where
F: FnOnce(Request<'a, 'out>) -> ProvideResult<'a, 'out>,
[src]
F: FnOnce(Request<'a, 'out>) -> ProvideResult<'a, 'out>,
Calls the provided closure with a request for the the type T
, returning
Some(&T)
if the request was fulfilled, and None
otherwise.
The ObjectProviderExt
trait provides helper methods specifically for
types implementing ObjectProvider
.
Trait Implementations
Auto Trait Implementations
impl<'r, 'out> !Send for Request<'r, 'out>
impl<'r, 'out> !Sync for Request<'r, 'out>
impl<'r, 'out> Unpin for Request<'r, 'out> where
'out: 'r,
'out: 'r,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,