pub trait AsyncRun<S>: 'static + Send {
// Required method
fn run(
&mut self,
stop: &mut StopTask<'_>,
_: &mut S,
) -> impl Send + Future<Output = Result<(), Cancelled>>;
}
Expand description
A method implemented by a task that can be run and stopped, storing
transient state in S
.
Required Methods§
Sourcefn run(
&mut self,
stop: &mut StopTask<'_>,
_: &mut S,
) -> impl Send + Future<Output = Result<(), Cancelled>>
fn run( &mut self, stop: &mut StopTask<'_>, _: &mut S, ) -> impl Send + Future<Output = Result<(), Cancelled>>
Runs the task.
The task should stop when stop
becomes ready. This can be determined
either by awaiting on stop
, or by calling StopTask::until_stopped
with a future to run.
The function should return Ok(())
if the task is complete, in which
case it will only run again after being removed and reinserted.
If the function instead returns Err(Cancelled)
, this indicates that
the task’s work is not complete, and it should be restarted after
handling any incoming events.
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.