pub trait Worker: Send {
// Required methods
fn id(&self) -> &WorkerId;
fn cancel_token(&self) -> CancellationToken;
fn join<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
Shared interface for the execution units spawners launch internally.
Every spawner implementation returns a concrete Worker struct that
implements this trait (today that is WorkerJoinHandler) as a
Box<dyn Worker>. The caller (the engine) only interacts with
workers through three operations: id() / cancel_token() /
join().
Required Methods§
Sourcefn id(&self) -> &WorkerId
fn id(&self) -> &WorkerId
This worker’s identity — used for logging and to tie cancellation back to the right worker.
Sourcefn cancel_token(&self) -> CancellationToken
fn cancel_token(&self) -> CancellationToken
Token that carries the cancel signal. Clonable — this is the path the engine uses to cancel from the outside.
Sourcefn join<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn join<'async_trait>(
self: Box<Self>,
) -> Pin<Box<dyn Future<Output = Result<(), WorkerError>> + Send + 'async_trait>>where
Self: 'async_trait,
Await the completion signal. The worker is consumed — one
worker, one join. Ok(()) means the worker ran to completion;
Err means it was cancelled, failed, or panicked internally.
Values do not come back through this trait; use
engine.output_tail for those.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".