pub struct BoxRunnableOnce<E> { /* private fields */ }Expand description
Box-based one-time runnable.
BoxRunnableOnce<E> stores a Box<dyn FnOnce() -> Result<(), E>> and can be
executed only once. It is the boxed concrete implementation of
RunnableOnce.
§Type Parameters
E- The error value returned when the action fails.
§Examples
use qubit_function::{BoxRunnableOnce, RunnableOnce};
let task = BoxRunnableOnce::new(|| Ok::<(), String>(()));
assert_eq!(task.run(), Ok(()));§Author
Haixing Hu
Implementations§
Source§impl<E> BoxRunnableOnce<E>
impl<E> BoxRunnableOnce<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) -> BoxRunnableOnce<E>where
N: RunnableOnce<E> + 'static,
E: 'static,
pub fn and_then<N>(self, next: N) -> BoxRunnableOnce<E>where
N: RunnableOnce<E> + 'static,
E: 'static,
Sourcepub fn then_callable<R, C>(self, callable: C) -> BoxCallableOnce<R, E>where
C: CallableOnce<R, E> + 'static,
R: 'static,
E: 'static,
pub fn then_callable<R, C>(self, callable: C) -> BoxCallableOnce<R, E>where
C: CallableOnce<R, E> + 'static,
R: 'static,
E: 'static,
Trait Implementations§
Source§impl<E> Debug for BoxRunnableOnce<E>
impl<E> Debug for BoxRunnableOnce<E>
Source§impl<E> Display for BoxRunnableOnce<E>
impl<E> Display for BoxRunnableOnce<E>
Source§impl<E> RunnableOnce<E> for BoxRunnableOnce<E>
impl<E> RunnableOnce<E> for BoxRunnableOnce<E>
Source§fn into_callable(self) -> BoxCallableOnce<(), E>where
Self: Sized + 'static,
fn into_callable(self) -> BoxCallableOnce<(), E>where
Self: Sized + 'static,
Converts this boxed runnable into a boxed callable while preserving its name.
Source§fn into_box(self) -> BoxRunnableOnce<E>
fn into_box(self) -> BoxRunnableOnce<E>
Converts this runnable into a boxed runnable. Read more
Auto Trait Implementations§
impl<E> Freeze for BoxRunnableOnce<E>
impl<E> !RefUnwindSafe for BoxRunnableOnce<E>
impl<E> !Send for BoxRunnableOnce<E>
impl<E> !Sync for BoxRunnableOnce<E>
impl<E> Unpin for BoxRunnableOnce<E>
impl<E> UnsafeUnpin for BoxRunnableOnce<E>
impl<E> !UnwindSafe for BoxRunnableOnce<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