pub trait ExitHandler: Send + 'static {
// Provided method
fn on_exit(&mut self) -> bool { ... }
}Expand description
Optional hook for agent cleanup on exit.
Implement this trait to run cleanup code before the application exits. This is useful for saving session state, closing connections, or other cleanup tasks.
§Example
ⓘ
struct SaveOnExitHandler {
session_file: PathBuf,
}
impl ExitHandler for SaveOnExitHandler {
fn on_exit(&mut self) -> bool {
// Save session state
self.save_session();
true // proceed with exit
}
}Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".