pub struct RcCallable<R, E> { /* private fields */ }Expand description
Single-threaded shared callable.
RcCallable<R, E> stores a Rc<RefCell<dyn FnMut() -> Result<R, E>>> and
can be called repeatedly through shared ownership.
§Type Parameters
R- The success value returned by the computation.E- The error value returned when the computation fails.
Implementations§
Source§impl<R, E> RcCallable<R, E>
impl<R, E> RcCallable<R, E>
Sourcepub fn new<F>(function: F) -> Self
pub fn new<F>(function: F) -> Self
Creates a new callable.
Wraps the provided closure in the appropriate smart pointer type for this 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 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 callable 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 callable.
Trait Implementations§
Source§impl<R, E> Callable<R, E> for RcCallable<R, E>
impl<R, E> Callable<R, E> for RcCallable<R, E>
Source§fn into_local_once(self) -> LocalBoxCallableOnce<R, E>where
Self: Sized + 'static,
fn into_local_once(self) -> LocalBoxCallableOnce<R, E>where
Self: Sized + 'static,
Converts this shared callable into a local boxed one-time callable while preserving its name.
Source§fn to_local_once(&self) -> LocalBoxCallableOnce<R, E>
fn to_local_once(&self) -> LocalBoxCallableOnce<R, E>
Converts this shared callable into a local boxed one-time callable
without consuming self.
Source§fn into_runnable(self) -> BoxRunnable<E>where
Self: Sized + 'static,
fn into_runnable(self) -> BoxRunnable<E>where
Self: Sized + 'static,
Converts this shared callable into a boxed runnable while preserving its name.
Source§fn into_box(self) -> BoxCallable<R, E>where
Self: 'static,
fn into_box(self) -> BoxCallable<R, E>where
Self: 'static,
Source§fn into_rc(self) -> RcCallable<R, E>
fn into_rc(self) -> RcCallable<R, E>
Rc callable. Read moreSource§fn into_fn(self) -> impl FnMut() -> Result<R, E>
fn into_fn(self) -> impl FnMut() -> Result<R, E>
Source§fn to_box(&self) -> BoxCallable<R, E>where
Self: 'static,
fn to_box(&self) -> BoxCallable<R, E>where
Self: 'static,
self. Read moreSource§fn to_rc(&self) -> RcCallable<R, E>
fn to_rc(&self) -> RcCallable<R, E>
Source§fn to_fn(&self) -> impl FnMut() -> Result<R, E>
fn to_fn(&self) -> impl FnMut() -> Result<R, E>
self. Read moreSource§fn into_arc(self) -> ArcCallable<R, E>
fn into_arc(self) -> ArcCallable<R, E>
Arc callable. Read more