pub trait KeyedWorker<K: WorkerKey>: Send + 'static {
// Required methods
fn is_work(&self) -> bool;
fn supports(&self, key: K) -> bool;
fn primary_key(&self) -> K;
}Expand description
A keyed worker managed by KeyedWorkerPool.
Methods on this trait may be called while the pool’s internal state lock is held. Implementations must be non-blocking and must not re-enter APIs on the same pool.
Required Methods§
fn is_work(&self) -> bool
Sourcefn supports(&self, key: K) -> bool
fn supports(&self, key: K) -> bool
Returns whether this worker can currently serve its requested primary key. Explicit keyed acquisition only reuses workers from that key’s primary bucket. A worker that is no longer valid for its cached primary key is discarded.
Sourcefn primary_key(&self) -> K
fn primary_key(&self) -> K
Returns the worker’s primary key used for accounting and replacement. The pool validates and caches this value when the worker is created. If it differs from the cached value when the worker is returned, the worker is discarded.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".