pub struct BoxRunnable<E> { /* private fields */ }Expand description
Box-based one-time runnable.
BoxRunnable<E> stores a Box<dyn FnOnce() -> Result<(), E>> and can be
executed only once. It is the boxed concrete implementation of
Runnable.
§Type Parameters
E- The error value returned when the action fails.
§Examples
use qubit_function::{BoxRunnable, Runnable};
let task = BoxRunnable::new(|| Ok::<(), String>(()));
assert_eq!(task.run(), Ok(()));§Author
Haixing Hu
Implementations§
Source§impl<E> BoxRunnable<E>
impl<E> BoxRunnable<E>
Sourcepub fn new_with_name<F>(name: &str, function: F) -> Self
pub fn new_with_name<F>(name: &str, function: F) -> Self
Sourcepub fn new_with_optional_name<F>(function: F, name: Option<String>) -> Self
pub fn new_with_optional_name<F>(function: F, name: Option<String>) -> Self
Sourcepub fn from_supplier<S>(supplier: S) -> Self
pub fn from_supplier<S>(supplier: S) -> Self
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
Clears the runnable name.
Sourcepub fn and_then<N>(self, next: N) -> BoxRunnable<E>where
N: Runnable<E> + 'static,
E: 'static,
pub fn and_then<N>(self, next: N) -> BoxRunnable<E>where
N: Runnable<E> + 'static,
E: 'static,
Sourcepub fn then_callable<R, C>(self, callable: C) -> BoxCallable<R, E>where
C: Callable<R, E> + 'static,
R: 'static,
E: 'static,
pub fn then_callable<R, C>(self, callable: C) -> BoxCallable<R, E>where
C: Callable<R, E> + 'static,
R: 'static,
E: 'static,
Trait Implementations§
Source§impl<E> Debug for BoxRunnable<E>
impl<E> Debug for BoxRunnable<E>
Source§impl<E> Display for BoxRunnable<E>
impl<E> Display for BoxRunnable<E>
Source§impl<E> Runnable<E> for BoxRunnable<E>
impl<E> Runnable<E> for BoxRunnable<E>
Source§fn into_box(self) -> BoxRunnable<E>
fn into_box(self) -> BoxRunnable<E>
Returns this boxed runnable without re-boxing it.
Source§fn into_callable(self) -> BoxCallable<(), E>where
Self: Sized + 'static,
fn into_callable(self) -> BoxCallable<(), E>where
Self: Sized + 'static,
Converts this boxed runnable into a boxed callable while preserving its name.
Auto Trait Implementations§
impl<E> Freeze for BoxRunnable<E>
impl<E> !RefUnwindSafe for BoxRunnable<E>
impl<E> !Send for BoxRunnable<E>
impl<E> !Sync for BoxRunnable<E>
impl<E> Unpin for BoxRunnable<E>
impl<E> UnsafeUnpin for BoxRunnable<E>
impl<E> !UnwindSafe for BoxRunnable<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more