#[repr(C)]pub struct Request<'a> { /* private fields */ }
Expand description
A dynamic request for an object based on its type.
Implementations§
Source§impl<'a> Request<'a>
impl<'a> Request<'a>
Sourcepub fn provide_ref<T: ?Sized + 'static>(
self: Pin<&mut Self>,
value: &'a T,
) -> Pin<&mut Self>
pub fn provide_ref<T: ?Sized + 'static>( 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.
Sourcepub fn provide_ref_with<T: ?Sized + 'static, F>(
self: Pin<&mut Self>,
cb: F,
) -> Pin<&mut Self>
pub fn provide_ref_with<T: ?Sized + 'static, F>( self: Pin<&mut Self>, cb: F, ) -> Pin<&mut Self>
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.
Sourcepub fn provide_value<T: 'static>(
self: Pin<&mut Self>,
value: T,
) -> Pin<&mut Self>
pub fn provide_value<T: 'static>( 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.
Sourcepub fn provide_value_with<T: 'static, F>(
self: Pin<&mut Self>,
cb: F,
) -> Pin<&mut Self>where
F: FnOnce() -> T,
pub fn provide_value_with<T: 'static, F>(
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.
Sourcepub fn request_ref<T: ?Sized + 'static, F>(f: F) -> Option<&'a T>
pub fn request_ref<T: ?Sized + 'static, F>(f: F) -> Option<&'a T>
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
.
Sourcepub fn request_value<T: 'static, F>(f: F) -> Option<T>
pub fn request_value<T: 'static, F>(f: F) -> Option<T>
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
.