pub struct ContextFormattingStyle {
pub function: FormattingFunction,
pub follow_source: bool,
pub follow_source_depth: Option<usize>,
}Expand description
Formatting preferences for a context when displayed in a report.
This struct allows a ContextHandler to specify how it prefers to be
formatted when its context is displayed as part of an error report. The
formatting system may or may not respect these preferences depending on the
formatter implementation.
§Fields
function: Whether to useDisplayorDebugformattingfollow_source: Whether to follow theError::source-chain whenContextHandler::sourcereturnsSome.follow_source_depth: How deep to follow the chain,Nonemeans no limit.
§Default
The default is to use FormattingFunction::Display and not to chase sources at all.
§Examples
use rootcause_internals::handlers::{ContextFormattingStyle, FormattingFunction};
// Prefer display formatting (the default)
let style = ContextFormattingStyle::default();
assert_eq!(style.function, FormattingFunction::Display);
// Explicitly request debug formatting
let debug_style = ContextFormattingStyle {
function: FormattingFunction::Debug,
follow_source: false,
follow_source_depth: None,
};Fields§
§function: FormattingFunctionThe preferred formatting function to use
follow_source: boolWhether to follow the core::error::Error source chain when
formatting
follow_source_depth: Option<usize>The maximum depth to follow the core::error::Error source chain when
formatting. Setting to None means unlimited depth.
Trait Implementations§
Source§impl Clone for ContextFormattingStyle
impl Clone for ContextFormattingStyle
Source§fn clone(&self) -> ContextFormattingStyle
fn clone(&self) -> ContextFormattingStyle
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextFormattingStyle
impl Debug for ContextFormattingStyle
Source§impl Default for ContextFormattingStyle
impl Default for ContextFormattingStyle
Source§fn default() -> ContextFormattingStyle
fn default() -> ContextFormattingStyle
Returns the “default value” for a type. Read more
impl Copy for ContextFormattingStyle
Auto Trait Implementations§
impl Freeze for ContextFormattingStyle
impl RefUnwindSafe for ContextFormattingStyle
impl Send for ContextFormattingStyle
impl Sync for ContextFormattingStyle
impl Unpin for ContextFormattingStyle
impl UnwindSafe for ContextFormattingStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more