Skip to main content

TaskRunner

Struct TaskRunner 

Source
pub struct TaskRunner<C> { /* private fields */ }
Expand description

Runner that executes a callable task with standard task-handle semantics.

TaskRunner owns the accepted callable, converts task failures and panics into TaskExecutionError, and can publish the final result through a TaskCompletion endpoint.

Implementations§

Source§

impl<C> TaskRunner<C>

Source

pub const fn new(task: C) -> Self

Creates a runner for the supplied callable task.

§Parameters
  • task - Callable task to execute later.
§Returns

A runner that owns the callable task.

Source

pub fn call<R, E>(self) -> TaskResult<R, E>
where C: Callable<R, E>,

Runs the callable and converts task failure and panic into a handle result.

§Returns

Ok(R) if the task succeeds. If the task returns Err(E) or panics, the corresponding TaskExecutionError is returned.

Source

pub fn run<R, E>(self, completion: TaskCompletion<R, E>) -> bool
where C: Callable<R, E>,

Runs this task through a task completion endpoint.

§Parameters
  • completion - Completion endpoint that publishes the final result.
§Returns

true if the task started and its result was published, or false if the completion endpoint had already been completed by cancellation.

Auto Trait Implementations§

§

impl<C> Freeze for TaskRunner<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for TaskRunner<C>
where C: RefUnwindSafe,

§

impl<C> Send for TaskRunner<C>
where C: Send,

§

impl<C> Sync for TaskRunner<C>
where C: Sync,

§

impl<C> Unpin for TaskRunner<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for TaskRunner<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for TaskRunner<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.