[][src]Struct object_provider::Request

#[repr(C)]pub struct Request<'a> { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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

impl<'a> Debug for Request<'a>[src]

Auto Trait Implementations

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.