pub struct LocalBoxCallableOnce<R, E> { /* private fields */ }Expand description
Local box-based one-time callable.
LocalBoxCallableOnce<R, E> stores a Box<dyn FnOnce() -> Result<R, E>>
and can be executed only once on the local thread. Use BoxCallableOnce
when the callable must be movable across threads.
§Type Parameters
R- The success value returned by the computation.E- The error value returned when the computation fails.
Implementations§
Source§impl<R, E> LocalBoxCallableOnce<R, E>
impl<R, E> LocalBoxCallableOnce<R, E>
Sourcepub fn new<F>(function: F) -> Self
pub fn new<F>(function: F) -> Self
Creates a new local callable.
Wraps the provided closure in the appropriate smart pointer type for this local callable 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 local callable.
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 local callable with an optional name.
Wraps the provided closure and assigns it an optional name.
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 name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Gets the name of this local callable.
§Returns
Returns Some(&str) if a name was set, None otherwise.
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
Clears the name of this local callable.
Sourcepub fn map<U, M>(self, mapper: M) -> LocalBoxCallableOnce<U, E>where
M: FnOnce(R) -> U + 'static,
R: 'static,
E: 'static,
pub fn map<U, M>(self, mapper: M) -> LocalBoxCallableOnce<U, E>where
M: FnOnce(R) -> U + 'static,
R: 'static,
E: 'static,
Sourcepub fn map_err<E2, M>(self, mapper: M) -> LocalBoxCallableOnce<R, E2>where
M: FnOnce(E) -> E2 + 'static,
R: 'static,
E: 'static,
pub fn map_err<E2, M>(self, mapper: M) -> LocalBoxCallableOnce<R, E2>where
M: FnOnce(E) -> E2 + 'static,
R: 'static,
E: 'static,
Sourcepub fn and_then<U, N>(self, next: N) -> LocalBoxCallableOnce<U, E>
pub fn and_then<U, N>(self, next: N) -> LocalBoxCallableOnce<U, E>
Trait Implementations§
Source§impl<R, E> CallableOnce<R, E> for LocalBoxCallableOnce<R, E>
impl<R, E> CallableOnce<R, E> for LocalBoxCallableOnce<R, E>
Source§fn into_local_box(self) -> LocalBoxCallableOnce<R, E>where
Self: Sized + 'static,
fn into_local_box(self) -> LocalBoxCallableOnce<R, E>where
Self: Sized + 'static,
Converts this local boxed callable into itself.
Source§fn into_fn(self) -> impl FnOnce() -> Result<R, E>where
Self: Sized + 'static,
fn into_fn(self) -> impl FnOnce() -> Result<R, E>where
Self: Sized + 'static,
Extracts the underlying local one-time closure.
Source§fn into_local_runnable(self) -> LocalBoxRunnableOnce<E>where
Self: Sized + 'static,
fn into_local_runnable(self) -> LocalBoxRunnableOnce<E>where
Self: Sized + 'static,
Converts this local boxed callable into a local boxed runnable while preserving its name.