Skip to main content

RunnableWith

Trait RunnableWith 

Source
pub trait RunnableWith<T, E> {
    // Required method
    fn run_with(&mut self, input: &mut T) -> Result<(), E>;

    // Provided methods
    fn into_box(self) -> BoxRunnableWith<T, E>
       where Self: Sized + 'static { ... }
    fn into_rc(self) -> RcRunnableWith<T, E>
       where Self: Sized + 'static { ... }
    fn into_arc(self) -> ArcRunnableWith<T, E>
       where Self: Sized + Send + 'static { ... }
    fn into_fn(self) -> impl FnMut(&mut T) -> Result<(), E>
       where Self: Sized + 'static { ... }
    fn to_box(&self) -> BoxRunnableWith<T, E>
       where Self: Clone + Sized + 'static { ... }
    fn to_rc(&self) -> RcRunnableWith<T, E>
       where Self: Clone + Sized + 'static { ... }
    fn to_arc(&self) -> ArcRunnableWith<T, E>
       where Self: Clone + Send + Sized + 'static { ... }
    fn to_fn(&self) -> impl FnMut(&mut T) -> Result<(), E>
       where Self: Clone + Sized + 'static { ... }
    fn into_callable_with(self) -> BoxCallableWith<T, (), E>
       where Self: Sized + 'static { ... }
}
Expand description

A fallible, reusable action that receives mutable input.

Conceptually this is FnMut(&mut T) -> Result<(), E> with task-oriented naming. It is useful for executor-style APIs that run an action with access to protected state, such as a value held under a lock.

§Type Parameters

  • T - The mutable input type.
  • E - The error value returned when the action fails.

§Author

Haixing Hu

Required Methods§

Source

fn run_with(&mut self, input: &mut T) -> Result<(), E>

Executes the action with mutable input.

§Parameters
  • input - The mutable input passed to this task.
§Returns

Returns Ok(()) when the action succeeds, or Err(E) when it fails. The exact error meaning is defined by the concrete runnable.

Provided Methods§

Source

fn into_box(self) -> BoxRunnableWith<T, E>
where Self: Sized + 'static,

Converts this runnable into a boxed runnable.

§Returns

A BoxRunnableWith<T, E>.

Source

fn into_rc(self) -> RcRunnableWith<T, E>
where Self: Sized + 'static,

Converts this runnable into an Rc runnable.

§Returns

A RcRunnableWith<T, E>.

Source

fn into_arc(self) -> ArcRunnableWith<T, E>
where Self: Sized + Send + 'static,

Converts this runnable into an Arc runnable.

§Returns

An ArcRunnableWith<T, E>.

Source

fn into_fn(self) -> impl FnMut(&mut T) -> Result<(), E>
where Self: Sized + 'static,

Converts this runnable into a mutable closure.

§Returns

A closure implementing FnMut(&mut T) -> Result<(), E>.

Source

fn to_box(&self) -> BoxRunnableWith<T, E>
where Self: Clone + Sized + 'static,

Converts this runnable into a boxed runnable without consuming self.

§Returns

A BoxRunnableWith<T, E> built from a clone of this runnable.

Source

fn to_rc(&self) -> RcRunnableWith<T, E>
where Self: Clone + Sized + 'static,

Converts this runnable into an Rc runnable without consuming self.

§Returns

A RcRunnableWith<T, E> built from a clone of this runnable.

Source

fn to_arc(&self) -> ArcRunnableWith<T, E>
where Self: Clone + Send + Sized + 'static,

Converts this runnable into an Arc runnable without consuming self.

§Returns

An ArcRunnableWith<T, E> built from a clone of this runnable.

Source

fn to_fn(&self) -> impl FnMut(&mut T) -> Result<(), E>
where Self: Clone + Sized + 'static,

Converts this runnable into a mutable closure without consuming self.

§Returns

A closure implementing FnMut(&mut T) -> Result<(), E>.

Source

fn into_callable_with(self) -> BoxCallableWith<T, (), E>
where Self: Sized + 'static,

Converts this runnable into a callable returning unit.

§Returns

A BoxCallableWith<T, (), E> that runs this task and returns unit on success.

Implementors§

Source§

impl<T, E> RunnableWith<T, E> for ArcRunnableWith<T, E>

Source§

impl<T, E> RunnableWith<T, E> for BoxRunnableWith<T, E>

Source§

impl<T, E> RunnableWith<T, E> for RcRunnableWith<T, E>

Source§

impl<T, E, F> RunnableWith<T, E> for F
where F: FnMut(&mut T) -> Result<(), E>,