[−][src]Struct object_provider::Request
A dynamic request for an object based on its type.
Implementations
impl<'a> Request<'a>
[src]
pub fn provide_ref<T: ?Sized + 'static>(
self: Pin<&mut Self>,
value: &'a T
) -> Pin<&mut Self>
[src]
self: Pin<&mut Self>,
value: &'a T
) -> Pin<&mut Self>
Provides a reference of type &'a T
in response to this request.
If a reference of type &'a T
has already been provided for this
request, the existing value will be replaced by the newly provided
value.
This method can be chained within provide
implementations to concisely
provide multiple objects.
pub fn provide_ref_with<T: ?Sized + 'static, F>(
self: Pin<&mut Self>,
cb: F
) -> Pin<&mut Self> where
F: FnOnce() -> &'a T,
[src]
self: Pin<&mut Self>,
cb: F
) -> Pin<&mut Self> where
F: FnOnce() -> &'a T,
Lazily provides a reference of type &'a T
in response to this request.
If a reference of type &'a T
has already been provided for this
request, the existing value will be replaced by the newly provided
value.
The passed closure is only called if the value will be successfully provided.
This method can be chained within provide
implementations to concisely
provide multiple objects.
pub fn provide_value<T: 'static>(
self: Pin<&mut Self>,
value: T
) -> Pin<&mut Self>
[src]
self: Pin<&mut Self>,
value: T
) -> Pin<&mut Self>
Provides an value of type T
in response to this request.
If a value of type T
has already been provided for this request, the
existing value will be replaced by the newly provided value.
This method can be chained within provide
implementations to concisely
provide multiple objects.
pub fn provide_value_with<T: 'static, F>(
self: Pin<&mut Self>,
cb: F
) -> Pin<&mut Self> where
F: FnOnce() -> T,
[src]
self: Pin<&mut Self>,
cb: F
) -> Pin<&mut Self> where
F: FnOnce() -> T,
Lazily provides a value of type T
in response to this request.
If a value of type T
has already been provided for this request, the
existing value will be replaced by the newly provided value.
The passed closure is only called if the value will be successfully provided.
This method can be chained within provide
implementations to concisely
provide multiple objects.
pub fn is_ref<T: ?Sized + 'static>(&self) -> bool
[src]
Returns true
if the requested type is &'a T
pub fn is_value<T: 'static>(&self) -> bool
[src]
Returns true
if the requested type is T
pub fn request_ref<T: ?Sized + 'static, F>(f: F) -> Option<&'a T> where
F: FnOnce(Pin<&mut Request<'a>>),
[src]
F: FnOnce(Pin<&mut Request<'a>>),
Calls the provided closure with a request for the the type &'a T
,
returning Some(&T)
if the request was fulfilled, and None
otherwise.
The ObjectProviderExt
trait provides helper methods specifically for
types implementing ObjectProvider
.
pub fn request_value<T: 'static, F>(f: F) -> Option<T> where
F: FnOnce(Pin<&mut Request<'a>>),
[src]
F: FnOnce(Pin<&mut Request<'a>>),
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
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>,