pub trait CallableWith<T, R, E> {
// Required method
fn call_with(&mut self, input: &mut T) -> Result<R, E>;
// Provided methods
fn into_box(self) -> BoxCallableWith<T, R, E>
where Self: Sized + 'static { ... }
fn into_rc(self) -> RcCallableWith<T, R, E>
where Self: Sized + 'static { ... }
fn into_arc(self) -> ArcCallableWith<T, R, E>
where Self: Sized + Send + 'static { ... }
fn into_fn(self) -> impl FnMut(&mut T) -> Result<R, E>
where Self: Sized + 'static { ... }
fn to_box(&self) -> BoxCallableWith<T, R, E>
where Self: Clone + Sized + 'static { ... }
fn to_rc(&self) -> RcCallableWith<T, R, E>
where Self: Clone + Sized + 'static { ... }
fn to_arc(&self) -> ArcCallableWith<T, R, E>
where Self: Clone + Send + Sized + 'static { ... }
fn to_fn(&self) -> impl FnMut(&mut T) -> Result<R, E>
where Self: Clone + Sized + 'static { ... }
fn into_runnable_with(self) -> BoxRunnableWith<T, E>
where Self: Sized + 'static { ... }
}Expand description
A fallible, reusable computation that receives mutable input.
Conceptually this is FnMut(&mut T) -> Result<R, E> with task-oriented
naming. It is useful for executor-style APIs that run a task with access to
protected state, such as a value held under a lock.
§Type Parameters
T- The mutable input type.R- The success value returned by the computation.E- The error value returned when the computation fails.
§Author
Haixing Hu
Required Methods§
Provided Methods§
Sourcefn into_box(self) -> BoxCallableWith<T, R, E>where
Self: Sized + 'static,
fn into_box(self) -> BoxCallableWith<T, R, E>where
Self: Sized + 'static,
Sourcefn into_rc(self) -> RcCallableWith<T, R, E>where
Self: Sized + 'static,
fn into_rc(self) -> RcCallableWith<T, R, E>where
Self: Sized + 'static,
Sourcefn into_arc(self) -> ArcCallableWith<T, R, E>
fn into_arc(self) -> ArcCallableWith<T, R, E>
Sourcefn into_fn(self) -> impl FnMut(&mut T) -> Result<R, E>where
Self: Sized + 'static,
fn into_fn(self) -> impl FnMut(&mut T) -> Result<R, E>where
Self: Sized + 'static,
Converts this callable into a mutable closure.
§Returns
A closure implementing FnMut(&mut T) -> Result<R, E>.
Sourcefn to_box(&self) -> BoxCallableWith<T, R, E>
fn to_box(&self) -> BoxCallableWith<T, R, E>
Converts this callable into a boxed callable without consuming self.
§Returns
A BoxCallableWith<T, R, E> built from a clone of this callable.
Sourcefn to_rc(&self) -> RcCallableWith<T, R, E>
fn to_rc(&self) -> RcCallableWith<T, R, E>
Converts this callable into an Rc callable without consuming self.
§Returns
A RcCallableWith<T, R, E> built from a clone of this callable.
Sourcefn to_arc(&self) -> ArcCallableWith<T, R, E>
fn to_arc(&self) -> ArcCallableWith<T, R, E>
Converts this callable into an Arc callable without consuming self.
§Returns
An ArcCallableWith<T, R, E> built from a clone of this callable.
Sourcefn to_fn(&self) -> impl FnMut(&mut T) -> Result<R, E>
fn to_fn(&self) -> impl FnMut(&mut T) -> Result<R, E>
Converts this callable into a mutable closure without consuming self.
§Returns
A closure implementing FnMut(&mut T) -> Result<R, E>.
Sourcefn into_runnable_with(self) -> BoxRunnableWith<T, E>where
Self: Sized + 'static,
fn into_runnable_with(self) -> BoxRunnableWith<T, E>where
Self: Sized + 'static,
Converts this callable into a runnable by discarding the success value.
§Returns
A BoxRunnableWith<T, E> preserving errors and mapping success to unit.