ContextHandler

Trait ContextHandler 

Source
pub trait ContextHandler<C>: 'static {
    // Required methods
    fn source(value: &C) -> Option<&(dyn Error + 'static)>;
    fn display(value: &C, formatter: &mut Formatter<'_>) -> Result;
    fn debug(value: &C, formatter: &mut Formatter<'_>) -> Result;

    // Provided method
    fn preferred_formatting_style(
        value: &C,
        report_formatting_function: FormattingFunction,
        report_formatting_alternate: bool,
    ) -> ContextFormattingStyle { ... }
}
Expand description

Handler used to implement or override the behavior of core::error::Error, core::fmt::Display and core::fmt::Debug when creating a report.

Required Methods§

Source

fn source(value: &C) -> Option<&(dyn Error + 'static)>

The function used when calling RawReportRef::context_source

Source

fn display(value: &C, formatter: &mut Formatter<'_>) -> Result

The function used when calling RawReportRef::context_display

Source

fn debug(value: &C, formatter: &mut Formatter<'_>) -> Result

The function used when calling RawReportRef::context_debug

Provided Methods§

Source

fn preferred_formatting_style( value: &C, report_formatting_function: FormattingFunction, report_formatting_alternate: bool, ) -> ContextFormattingStyle

The formatting style preferred by the context when formatted as part of a report.

§Arguments
  • report_formatting_function: Whether the report in which this context will be embedded is being formatted using Display formatting or Debug
  • report_formatting_alternate: Whether the report in which this context will be embedded is being formatted using the alternate mode

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§