Trait TaskExt

Source
pub trait TaskExt: Task + Sized {
    // Required methods
    fn cancelable(self) -> (CancelableTask<Self>, Sender<()>);
    fn cancelable_loop(self) -> (CancelableLoop<Self>, Sender<()>);
    fn with_delay(self, poll_delay: Duration) -> WithDelay<Self>
       where Self::Output: Into<bool>;
    fn into_bg(self) -> JoinHandle<Result<Self::Output, BridgeError>> ;
    fn into_buffered_errors(
        self,
        error_overflow_limit: usize,
        handle_error_attempts: usize,
        wait_between_recover_attempts: Duration,
    ) -> BufferedErrors<Self>
       where Self: RecoverableTask,
             Self::Output: Default;
    fn map<F: Fn(Self::Output) -> Self::Output + Send + Sync + 'static>(
        self,
        map: F,
    ) -> Map<Self, F>;
    fn ignore_error(self) -> IgnoreError<Self>
       where Self::Output: Default;
}

Required Methods§

Source

fn cancelable(self) -> (CancelableTask<Self>, Sender<()>)

Skips running the task after cancellation using the sender.

Source

fn cancelable_loop(self) -> (CancelableLoop<Self>, Sender<()>)

Runs the task in an infinite loop until cancelled using the sender.

Source

fn with_delay(self, poll_delay: Duration) -> WithDelay<Self>
where Self::Output: Into<bool>,

Adds the given delay after a run of the task when the task returns false.

Source

fn into_bg(self) -> JoinHandle<Result<Self::Output, BridgeError>>

Spawns a [tokio::task] that runs the task once in the background.

Source

fn into_buffered_errors( self, error_overflow_limit: usize, handle_error_attempts: usize, wait_between_recover_attempts: Duration, ) -> BufferedErrors<Self>
where Self: RecoverableTask, Self::Output: Default,

Buffers consecutive errors until the task succeeds, emits all errors when there are more than error_overflow_limit consecutive errors. If the task fails, error will be tried to be handled up to handle_error_attempts times. After each attempt, the task will wait for wait_between_recover_attempts before trying again.

Source

fn map<F: Fn(Self::Output) -> Self::Output + Send + Sync + 'static>( self, map: F, ) -> Map<Self, F>

Maps the task’s Ok() output using the given function.

Source

fn ignore_error(self) -> IgnoreError<Self>
where Self::Output: Default,

Ignores errors from the task.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Task + Sized> TaskExt for T