pub trait Runnable<E> {
// Required method
fn run(self) -> Result<(), E>;
// Provided methods
fn into_box(self) -> BoxRunnable<E>
where Self: Sized + 'static { ... }
fn into_fn(self) -> impl FnOnce() -> Result<(), E>
where Self: Sized + 'static { ... }
fn to_box(&self) -> BoxRunnable<E>
where Self: Clone + Sized + 'static { ... }
fn to_fn(&self) -> impl FnOnce() -> Result<(), E>
where Self: Clone + Sized + 'static { ... }
fn into_callable(self) -> BoxCallable<(), E>
where Self: Sized + 'static { ... }
}Expand description
A fallible one-time action.
Runnable<E> consumes itself and returns Result<(), E>. It is a semantic
specialization of SupplierOnce<Result<(), E>> for executable actions and
deferred side effects.
§Type Parameters
E- The error value returned when the action fails.
§Examples
use qubit_function::Runnable;
let task = || Ok::<(), String>(());
assert_eq!(task.run(), Ok(()));§Author
Haixing Hu
Required Methods§
Provided Methods§
Sourcefn into_box(self) -> BoxRunnable<E>where
Self: Sized + 'static,
fn into_box(self) -> BoxRunnable<E>where
Self: Sized + 'static,
Converts this runnable into a boxed runnable.
§Returns
A BoxRunnable<E> that executes this runnable when run() is invoked.
Sourcefn to_box(&self) -> BoxRunnable<E>
fn to_box(&self) -> BoxRunnable<E>
Converts this runnable into a boxed runnable without consuming self.
The method clones self and boxes the clone. Use this for cloneable
runnable values that need to be reused after boxing.
§Returns
A new BoxRunnable<E> built from a clone of this runnable.
Sourcefn to_fn(&self) -> impl FnOnce() -> Result<(), E>
fn to_fn(&self) -> impl FnOnce() -> Result<(), E>
Converts this runnable into a closure without consuming self.
The method clones self and returns a one-time closure that executes
the clone.
§Returns
A closure implementing FnOnce() -> Result<(), E>.
Sourcefn into_callable(self) -> BoxCallable<(), E>where
Self: Sized + 'static,
fn into_callable(self) -> BoxCallable<(), E>where
Self: Sized + 'static,
Converts this runnable into a callable returning unit.
§Returns
A BoxCallable<(), E> that executes this runnable and returns
Ok(()) on success.