pub trait Resumable: Send + 'static {
// Required method
fn run(
&mut self,
stop: ShutdownHandle,
) -> impl Future<Output = Result<(), GenericError>> + Send + '_;
// Provided method
fn shutdown_strategy(&self) -> ShutdownStrategy { ... }
}Expand description
Work whose state outlives the worker that runs it.
The state is self. A ResumableWorker calls run each time it starts, and each call continues from
whatever the previous call left in self.
Required Methods§
Sourcefn run(
&mut self,
stop: ShutdownHandle,
) -> impl Future<Output = Result<(), GenericError>> + Send + '_
fn run( &mut self, stop: ShutdownHandle, ) -> impl Future<Output = Result<(), GenericError>> + Send + '_
Runs the work until stop resolves.
Once stop resolves, return at the next point where stopping loses no work. A call can also be dropped at any
await point, when its owner halts it or it is cancelled before supervision, so every await point must leave
self able to continue. Record work in flight that can’t be repeated, and don’t race it against stop if
stopping must lose nothing.
The worker ends when this returns, and its owner then applies its restart policy. Work that can run out of
things to do waits for stop, returns an error, or runs in a worker that is added as a hosted child.
§Errors
An error ends the worker that runs this call, and its owner restarts it or fails, according to its restart policy.
Provided Methods§
Sourcefn shutdown_strategy(&self) -> ShutdownStrategy
fn shutdown_strategy(&self) -> ShutdownStrategy
Returns the shutdown strategy of the worker that runs this work.
ResumableWorker calls this once, when it is created. Defaults to a graceful shutdown with a five-second
timeout.
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.