Skip to main content

TaskCx

Struct TaskCx 

Source
pub struct TaskCx<Msg> { /* private fields */ }
Expand description

What running work can do: report progress, send messages, notice cancellation and sleep.

Implementations§

Source§

impl<Msg: Send + 'static> TaskCx<Msg>

Source

pub fn id(&self) -> TaskId

The running task.

Source

pub fn progress(&self, fraction: f32)

Reports the completed share, from 0 to 1.

Source

pub fn note(&self, note: impl Into<String>)

Describes the current step, e.g. “pushing layers”.

Source

pub fn send(&self, message: Msg)

Delivers message to the application while the work goes on, e.g. a log line.

Source

pub fn is_cancelled(&self) -> bool

Whether the application asked this task to stop. Long work should check it and return.

Source

pub fn sleep(&self, duration: Duration) -> bool

Waits duration, waking early when the task is cancelled. Returns false when it was cancelled. In tests the harness’s fake clock decides when the sleep ends.

Auto Trait Implementations§

§

impl<Msg> !RefUnwindSafe for TaskCx<Msg>

§

impl<Msg> !UnwindSafe for TaskCx<Msg>

§

impl<Msg> Freeze for TaskCx<Msg>
where Arc<dyn Fn(Msg) + Send + Sync>: Freeze,

§

impl<Msg> Send for TaskCx<Msg>
where Arc<dyn Fn(Msg) + Send + Sync>: Send,

§

impl<Msg> Sync for TaskCx<Msg>
where Arc<dyn Fn(Msg) + Send + Sync>: Sync,

§

impl<Msg> Unpin for TaskCx<Msg>
where Arc<dyn Fn(Msg) + Send + Sync>: Unpin,

§

impl<Msg> UnsafeUnpin for TaskCx<Msg>
where Arc<dyn Fn(Msg) + Send + Sync>: UnsafeUnpin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.