pub trait WorkerHandle: Send + 'static {
// Required methods
fn id(&self) -> u32;
fn ready<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 mut self,
method: &'life1 str,
payload: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn terminate<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn is_recyclable(&self) -> bool { ... }
}Expand description
A handle to a spawned worker.
The pool dispatches requests via execute and controls lifecycle via
ready and terminate.
Required Methods§
Sourcefn ready<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ready<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Wait for the worker to signal readiness. Returns once the worker has booted and is ready to accept requests.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 mut self,
method: &'life1 str,
payload: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 mut self,
method: &'life1 str,
payload: Value,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a single request: send structured data, receive result.
Provided Methods§
Sourcefn is_recyclable(&self) -> bool
fn is_recyclable(&self) -> bool
Whether this worker can be recycled (terminated and respawned).
Returns false for the main thread worker which cannot be restarted.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".