Skip to main content

Handler

Trait Handler 

Source
pub trait Handler: Any {
    // Required methods
    fn report(&mut self, diagnostic: Box<dyn Diagnostic>);
    fn drain(&mut self) -> Result<(), DrainError>;

    // Provided method
    fn report_and_drain(
        &mut self,
        diagnostic: Box<dyn Diagnostic>,
    ) -> Result<(), DrainError> { ... }
}
Expand description

Abstract handler type for reporting diagnostics.

Handlers are nothing more than a “store” for diagnostics, which decides when to drain the diagnostics to the user.

Required Methods§

Source

fn report(&mut self, diagnostic: Box<dyn Diagnostic>)

Reports the diagnostic to the handler, without emitting it immediately.

Source

fn drain(&mut self) -> Result<(), DrainError>

Drains all the diagnostics to the console and empties the local store.

Provided Methods§

Source

fn report_and_drain( &mut self, diagnostic: Box<dyn Diagnostic>, ) -> Result<(), DrainError>

Reports the diagnostic to the handler and emits it immediately, along with all other stored diagnostics within the handler.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§