pub struct BoxRunnable<E> { /* private fields */ }Expand description
Box-based reusable runnable.
BoxRunnable<E> stores a Box<dyn FnMut() -> Result<(), E>> and can be
executed repeatedly. 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 mut 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<F>(function: F) -> Self
pub fn new<F>(function: F) -> Self
Creates a new runnable.
Wraps the provided closure in the appropriate smart pointer type for this runnable implementation.
Sourcepub fn new_with_name<F>(name: &str, function: F) -> Self
pub fn new_with_name<F>(name: &str, function: F) -> Self
Creates a new named runnable.
Wraps the provided closure and assigns it a name, which is useful for debugging and logging purposes.
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
Creates a new named runnable with an optional name.
Wraps the provided closure and assigns it an optional name.
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 name of this runnable.
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_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.
Source§fn into_box(self) -> BoxRunnable<E>
fn into_box(self) -> BoxRunnable<E>
Converts this runnable into a boxed runnable. Read more
Source§fn into_rc(self) -> RcRunnable<E>where
Self: 'static,
fn into_rc(self) -> RcRunnable<E>where
Self: 'static,
Converts this runnable into a shared single-threaded runnable. Read more
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