pub struct BoxCallable<R, E> { /* private fields */ }Expand description
Box-based one-time callable.
BoxCallable<R, E> stores a Box<dyn FnOnce() -> Result<R, E>> and can be
executed only once. It is the boxed concrete implementation of
Callable.
§Type Parameters
R- The success value returned by the computation.E- The error value returned when the computation fails.
§Examples
use qubit_function::{BoxCallable, Callable};
let task = BoxCallable::new(|| Ok::<i32, String>(42));
assert_eq!(task.call(), Ok(42));§Author
Haixing Hu
Implementations§
Source§impl<R, E> BoxCallable<R, E>
impl<R, E> BoxCallable<R, 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) -> Selfwhere
S: SupplierOnce<Result<R, E>> + 'static,
pub fn from_supplier<S>(supplier: S) -> Selfwhere
S: SupplierOnce<Result<R, E>> + 'static,
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
Clears the callable name.
Sourcepub fn map<U, M>(self, mapper: M) -> BoxCallable<U, E>where
M: FnOnce(R) -> U + 'static,
R: 'static,
E: 'static,
pub fn map<U, M>(self, mapper: M) -> BoxCallable<U, E>where
M: FnOnce(R) -> U + 'static,
R: 'static,
E: 'static,
Sourcepub fn map_err<E2, M>(self, mapper: M) -> BoxCallable<R, E2>where
M: FnOnce(E) -> E2 + 'static,
R: 'static,
E: 'static,
pub fn map_err<E2, M>(self, mapper: M) -> BoxCallable<R, E2>where
M: FnOnce(E) -> E2 + 'static,
R: 'static,
E: 'static,
Sourcepub fn and_then<U, N>(self, next: N) -> BoxCallable<U, E>
pub fn and_then<U, N>(self, next: N) -> BoxCallable<U, E>
Trait Implementations§
Source§impl<R, E> Callable<R, E> for BoxCallable<R, E>
impl<R, E> Callable<R, E> for BoxCallable<R, E>
Source§fn into_box(self) -> BoxCallable<R, E>
fn into_box(self) -> BoxCallable<R, E>
Returns this boxed callable without re-boxing it.
Source§fn into_runnable(self) -> BoxRunnable<E>where
Self: Sized + 'static,
fn into_runnable(self) -> BoxRunnable<E>where
Self: Sized + 'static,
Converts this boxed callable into a boxed runnable while preserving its name.
Source§impl<R, E> Debug for BoxCallable<R, E>
impl<R, E> Debug for BoxCallable<R, E>
Source§impl<R, E> Display for BoxCallable<R, E>
impl<R, E> Display for BoxCallable<R, E>
Source§impl<R, E> SupplierOnce<Result<R, E>> for BoxCallable<R, E>
impl<R, E> SupplierOnce<Result<R, E>> for BoxCallable<R, E>
Auto Trait Implementations§
impl<R, E> Freeze for BoxCallable<R, E>
impl<R, E> !RefUnwindSafe for BoxCallable<R, E>
impl<R, E> !Send for BoxCallable<R, E>
impl<R, E> !Sync for BoxCallable<R, E>
impl<R, E> Unpin for BoxCallable<R, E>
impl<R, E> UnsafeUnpin for BoxCallable<R, E>
impl<R, E> !UnwindSafe for BoxCallable<R, 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