pub struct LocalBoxRunnableOnce<E> { /* private fields */ }Expand description
Local box-based one-time runnable.
LocalBoxRunnableOnce<E> stores a Box<dyn FnOnce() -> Result<(), E>> and
can be executed only once on the local thread. Use BoxRunnableOnce when
the runnable must be movable across threads.
§Type Parameters
E- The error value returned when the action fails.
Implementations§
Source§impl<E> LocalBoxRunnableOnce<E>
impl<E> LocalBoxRunnableOnce<E>
Sourcepub fn new<F>(function: F) -> Self
pub fn new<F>(function: F) -> Self
Creates a new local runnable.
Wraps the provided closure in the appropriate smart pointer type for this local 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 local 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 local 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 name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Gets the name of this local runnable.
§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 runnable.
Sourcepub fn and_then<N>(self, next: N) -> LocalBoxRunnableOnce<E>where
N: RunnableOnce<E> + 'static,
E: 'static,
pub fn and_then<N>(self, next: N) -> LocalBoxRunnableOnce<E>where
N: RunnableOnce<E> + 'static,
E: 'static,
Sourcepub fn then_callable<R, C>(self, callable: C) -> LocalBoxCallableOnce<R, E>where
C: CallableOnce<R, E> + 'static,
R: 'static,
E: 'static,
pub fn then_callable<R, C>(self, callable: C) -> LocalBoxCallableOnce<R, E>where
C: CallableOnce<R, E> + 'static,
R: 'static,
E: 'static,
Trait Implementations§
Source§impl<E> Debug for LocalBoxRunnableOnce<E>
impl<E> Debug for LocalBoxRunnableOnce<E>
Source§impl<E> Display for LocalBoxRunnableOnce<E>
impl<E> Display for LocalBoxRunnableOnce<E>
Source§impl<E> RunnableOnce<E> for LocalBoxRunnableOnce<E>
impl<E> RunnableOnce<E> for LocalBoxRunnableOnce<E>
Source§fn into_local_box(self) -> LocalBoxRunnableOnce<E>where
Self: Sized + 'static,
fn into_local_box(self) -> LocalBoxRunnableOnce<E>where
Self: Sized + 'static,
Converts this local boxed runnable into itself.
Source§fn into_fn(self) -> impl FnOnce() -> Result<(), E>where
Self: Sized + 'static,
fn into_fn(self) -> impl FnOnce() -> Result<(), E>where
Self: Sized + 'static,
Extracts the underlying local one-time closure.
Source§fn into_local_callable(self) -> LocalBoxCallableOnce<(), E>where
Self: Sized + 'static,
fn into_local_callable(self) -> LocalBoxCallableOnce<(), E>where
Self: Sized + 'static,
Converts this local boxed runnable into a local boxed callable while preserving its name.