[][src]Trait witcher::Wrapper

pub trait Wrapper<T, E> {
    pub fn pass(self) -> Result<T>;
pub fn wrap(self, msg: &str) -> Result<T>;
pub fn err_is<U>(&self) -> bool
    where
        U: StdError + 'static
;
pub fn retry<F>(self, max: usize, f: F) -> Result<T, E>
    where
        F: Fn(usize) -> Result<T, E>
;
pub fn retry_on<F>(self, max: usize, id: TypeId, f: F) -> Result<T, E>
    where
        F: Fn(usize) -> Result<T, E>
; }

Define the wrap function for Result types

Required methods

pub fn pass(self) -> Result<T>[src]

Pass the error through without any message. This is useful to keep compatibility without having to unwrap the error.

pub fn wrap(self, msg: &str) -> Result<T>[src]

Wrap the error providing the ability to add more context

pub fn err_is<U>(&self) -> bool where
    U: StdError + 'static, 
[src]

Check if there is an error and the err is the given error type

pub fn retry<F>(self, max: usize, f: F) -> Result<T, E> where
    F: Fn(usize) -> Result<T, E>, 
[src]

Retry the given function when we have an error max number of times.

pub fn retry_on<F>(self, max: usize, id: TypeId, f: F) -> Result<T, E> where
    F: Fn(usize) -> Result<T, E>, 
[src]

Retry the given function when we have the concreate error U max number of times.

Loading content...

Implementors

impl<T, E> Wrapper<T, E> for Result<T, E> where
    E: StdError + Send + Sync + 'static, 
[src]

Loading content...