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§
Sourcefn cancelable(self) -> (CancelableTask<Self>, Sender<()>)
fn cancelable(self) -> (CancelableTask<Self>, Sender<()>)
Skips running the task after cancellation using the sender.
Sourcefn cancelable_loop(self) -> (CancelableLoop<Self>, Sender<()>)
fn cancelable_loop(self) -> (CancelableLoop<Self>, Sender<()>)
Runs the task in an infinite loop until cancelled using the sender.
Sourcefn with_delay(self, poll_delay: Duration) -> WithDelay<Self>
fn with_delay(self, poll_delay: Duration) -> WithDelay<Self>
Adds the given delay after a run of the task when the task returns false.
Sourcefn into_bg(self) -> JoinHandle<Result<Self::Output, BridgeError>> ⓘ
fn into_bg(self) -> JoinHandle<Result<Self::Output, BridgeError>> ⓘ
Spawns a [tokio::task] that runs the task once in the background.
Sourcefn into_buffered_errors(
self,
error_overflow_limit: usize,
handle_error_attempts: usize,
wait_between_recover_attempts: Duration,
) -> BufferedErrors<Self>
fn into_buffered_errors( self, error_overflow_limit: usize, handle_error_attempts: usize, wait_between_recover_attempts: Duration, ) -> BufferedErrors<Self>
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.
Sourcefn map<F: Fn(Self::Output) -> Self::Output + Send + Sync + 'static>(
self,
map: F,
) -> Map<Self, F>
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.
Sourcefn ignore_error(self) -> IgnoreError<Self>
fn ignore_error(self) -> IgnoreError<Self>
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.