pub trait EventHandler: Send {
// Provided methods
fn on_start(&mut self, worker: &dyn Worker) { ... }
fn on_read(&mut self, node: &str, fd: RawFd, msg: &[u8]) { ... }
fn on_close(&mut self, node: &str, rc: i32) { ... }
fn on_timeout(&mut self, node: &str) { ... }
fn on_error(&mut self, node: &str, error: &WorkerError) { ... }
fn take_buffers(
&mut self,
) -> (HashMap<String, Vec<Vec<u8>>>, HashMap<String, Vec<Vec<u8>>>, HashSet<String>) { ... }
}Expand description
Event handler trait for worker events.
Implement this trait to receive notifications about worker events.
Provided Methods§
Sourcefn on_read(&mut self, node: &str, fd: RawFd, msg: &[u8])
fn on_read(&mut self, node: &str, fd: RawFd, msg: &[u8])
Called when data is available for reading from a node.
Sourcefn on_timeout(&mut self, node: &str)
fn on_timeout(&mut self, node: &str)
Called when a node operation times out.
Sourcefn on_error(&mut self, node: &str, error: &WorkerError)
fn on_error(&mut self, node: &str, error: &WorkerError)
Called when an error occurs for a node.
Sourcefn take_buffers(
&mut self,
) -> (HashMap<String, Vec<Vec<u8>>>, HashMap<String, Vec<Vec<u8>>>, HashSet<String>)
fn take_buffers( &mut self, ) -> (HashMap<String, Vec<Vec<u8>>>, HashMap<String, Vec<Vec<u8>>>, HashSet<String>)
Extract buffered stdout/stderr data from this handler.
Returns (stdout, stderr, timeouts) where stdout/stderr are node -> Vec<chunks>.
Default returns empty maps. Used by Task to collect results after execution.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".