pub trait ReportHandler:
Any
+ Send
+ Sync {
// Required method
fn debug(
&self,
error: &dyn Diagnostic,
f: &mut Formatter<'_>,
) -> Result<(), Error>;
// Provided methods
fn display(
&self,
error: &(dyn Error + 'static),
f: &mut Formatter<'_>,
) -> Result<(), Error> { ... }
fn track_caller(&mut self, location: &'static Location<'static>) { ... }
}Expand description
Error Report Handler trait for customizing miette::Report
Required Methods§
Sourcefn debug(
&self,
error: &dyn Diagnostic,
f: &mut Formatter<'_>,
) -> Result<(), Error>
fn debug( &self, error: &dyn Diagnostic, f: &mut Formatter<'_>, ) -> Result<(), Error>
Define the report format
Used to override the report format of miette::Report
§Example
use indenter::indented;
use miette::{Diagnostic, ReportHandler};
pub struct Handler;
impl ReportHandler for Handler {
fn debug(
&self,
error: &dyn Diagnostic,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
use core::fmt::Write as _;
if f.alternate() {
return core::fmt::Debug::fmt(error, f);
}
write!(f, "{}", error)?;
Ok(())
}
}Provided Methods§
Sourcefn display(
&self,
error: &(dyn Error + 'static),
f: &mut Formatter<'_>,
) -> Result<(), Error>
fn display( &self, error: &(dyn Error + 'static), f: &mut Formatter<'_>, ) -> Result<(), Error>
Override for the Display format
Sourcefn track_caller(&mut self, location: &'static Location<'static>)
fn track_caller(&mut self, location: &'static Location<'static>)
Store the location of the caller who constructed this error report
Implementations§
Source§impl dyn ReportHandler
impl dyn ReportHandler
Sourcepub fn is<T>(&self) -> boolwhere
T: ReportHandler,
pub fn is<T>(&self) -> boolwhere
T: ReportHandler,
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ReportHandler,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ReportHandler,
Sourcepub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: ReportHandler,
pub fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: ReportHandler,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".