[][src]Struct sealrs::futures::future::WrappedFuture

pub struct WrappedFuture<V: Send + Clone + 'static, E: Send + Clone + 'static> {
    pub inner: TSafe<Future<V, E>>,
}

Wrapper for future. This object encapsulate original future and allows to user set of simplified methods mirrored from the original future (read as methods with sweetened syntax).

Fields

inner: TSafe<Future<V, E>>

Methods

impl<V: Send + Clone, E: Send + Clone> WrappedFuture<V, E>[src]

pub fn map<S, F>(&mut self, f: F) -> WrappedFuture<S, E> where
    S: Send + Clone + 'static,
    F: FnMut(&V) -> Result<S, E> + Send + 'static, 
[src]

Callback that will be called upon completion of the future. Creates and returns new future, which value is the result of function f applied to the current value if it is has 'Ok' type. Else function f does not applied, and current value inserted to the next future as is.

Examples

See the module level documentation.

pub fn recover<F>(&mut self, f: F) -> WrappedFuture<V, E> where
    F: FnMut(&E) -> Result<V, E> + Send + 'static, 
[src]

Callback that will be called upon completion of the future. Creates and returns new future, which value is the result of function f applied to the current value if it is has 'Err' type. Else function f does not applied, and current value inserted to the next future as is.

Examples

See the module level documentation.

pub fn map_err<X, F>(&mut self, f: F) -> WrappedFuture<V, X> where
    X: Send + Clone + 'static,
    F: FnMut(&E) -> Result<V, X> + Send + 'static, 
[src]

Callback that will be called upon completion of the future. Creates and returns new future, which error is the result of function f applied to the current error if it is has 'Err' type. Else function f does not applied, and current value inserted to the next future as is.

Examples

See the module level documentation.

pub fn flat_map<S, F>(&mut self, f: F) -> WrappedFuture<S, E> where
    S: Send + Clone + 'static,
    F: FnMut(&V) -> Result<WrappedFuture<S, E>, E> + Send + 'static, 
[src]

Callback that will be called upon completion of the future. Creates and returns new future, which value is the result of completion of the future returned by the function f.

Examples

See the module level documentation.

pub fn on_complete<F>(&mut self, f: F) where
    F: FnMut(&Result<V, E>) + Send + 'static, 
[src]

Callback that will be called upon completion of the future. Passes the future value as a function argument.

Examples

See the module level documentation.

pub fn is_completed(&self) -> bool[src]

Return completion state of the future

pub fn ready(&mut self, timeout: Duration) -> bool[src]

Waits (blocks calling thread) while future will be completed in a specified timeout. If future was completed before timeout was reached, true will be returned. If timeout occurs, returned false.

pub fn result(
    &mut self,
    timeout: Duration
) -> Result<Result<V, E>, TimeoutError>
[src]

Waits (blocks calling thread) while future will be completed in a specified timeout. If future was completed before timeout was reached, value of future packed in Ok will be returned. If timeout occurs, returned Err(TimeoutError).

pub fn get_value(&self) -> Result<V, E>[src]

Returns value of the completed future. Attention - this method must never be called on the empty future! If this situation will happen, panic will be occurs.

Auto Trait Implementations

impl<V, E> Sync for WrappedFuture<V, E>

impl<V, E> Send for WrappedFuture<V, E>

impl<V, E> Unpin for WrappedFuture<V, E>

impl<V, E> RefUnwindSafe for WrappedFuture<V, E>

impl<V, E> UnwindSafe for WrappedFuture<V, E>

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

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