Struct GraphicalReportHandler
pub struct GraphicalReportHandler { /* private fields */ }Expand description
A ReportHandler that displays a given Report in a
quasi-graphical way, using terminal colors, unicode drawing characters, and
other such things.
This is the default reporter bundled with miette.
This printer can be customized by using new_themed() and handing it a
GraphicalTheme of your own creation (or using one of its own defaults!)
See set_hook() for more details on customizing your global
printer.
Implementations§
§impl GraphicalReportHandler
impl GraphicalReportHandler
pub fn new() -> GraphicalReportHandler
pub fn new() -> GraphicalReportHandler
Create a new GraphicalReportHandler with the default
GraphicalTheme. This will use both unicode characters and colors.
pub fn new_themed(theme: GraphicalTheme) -> GraphicalReportHandler
pub fn new_themed(theme: GraphicalTheme) -> GraphicalReportHandler
Create a new GraphicalReportHandler with a given GraphicalTheme.
pub fn tab_width(self, width: usize) -> GraphicalReportHandler
pub fn tab_width(self, width: usize) -> GraphicalReportHandler
Set the displayed tab width in spaces.
pub fn with_links(self, links: bool) -> GraphicalReportHandler
pub fn with_links(self, links: bool) -> GraphicalReportHandler
Whether to enable error code linkification using Diagnostic::url().
pub fn with_cause_chain(self) -> GraphicalReportHandler
pub fn with_cause_chain(self) -> GraphicalReportHandler
Include the cause chain of the top-level error in the graphical output, if available.
pub fn without_cause_chain(self) -> GraphicalReportHandler
pub fn without_cause_chain(self) -> GraphicalReportHandler
Do not include the cause chain of the top-level error in the graphical output.
pub fn with_urls(self, urls: bool) -> GraphicalReportHandler
pub fn with_urls(self, urls: bool) -> GraphicalReportHandler
Whether to include Diagnostic::url() in the output.
Disabling this is not recommended, but can be useful for more easily
reproducible tests, as url(docsrs) links are version-dependent.
pub fn with_theme(self, theme: GraphicalTheme) -> GraphicalReportHandler
pub fn with_theme(self, theme: GraphicalTheme) -> GraphicalReportHandler
Set a theme for this handler.
pub fn with_width(self, width: usize) -> GraphicalReportHandler
pub fn with_width(self, width: usize) -> GraphicalReportHandler
Sets the width to wrap the report at.
pub fn with_wrap_lines(self, wrap_lines: bool) -> GraphicalReportHandler
pub fn with_wrap_lines(self, wrap_lines: bool) -> GraphicalReportHandler
Enables or disables wrapping of lines to fit the width.
pub fn with_break_words(self, break_words: bool) -> GraphicalReportHandler
pub fn with_break_words(self, break_words: bool) -> GraphicalReportHandler
Enables or disables breaking of words during wrapping.
pub fn with_word_separator(
self,
word_separator: WordSeparator,
) -> GraphicalReportHandler
pub fn with_word_separator( self, word_separator: WordSeparator, ) -> GraphicalReportHandler
Sets the word separator to use when wrapping.
pub fn with_word_splitter(
self,
word_splitter: WordSplitter,
) -> GraphicalReportHandler
pub fn with_word_splitter( self, word_splitter: WordSplitter, ) -> GraphicalReportHandler
Sets the word splitter to usewhen wrapping.
Sets the ‘global’ footer for this handler.
pub fn with_context_lines(self, lines: usize) -> GraphicalReportHandler
pub fn with_context_lines(self, lines: usize) -> GraphicalReportHandler
Sets the number of lines of context to show around each error.
pub fn with_syntax_highlighting(
self,
highlighter: impl Highlighter + Send + Sync + 'static,
) -> GraphicalReportHandler
pub fn with_syntax_highlighting( self, highlighter: impl Highlighter + Send + Sync + 'static, ) -> GraphicalReportHandler
Enable syntax highlighting for source code snippets, using the given
[Highlighter]. See the [crate::highlighters] crate for more details.
pub fn without_syntax_highlighting(self) -> GraphicalReportHandler
pub fn without_syntax_highlighting(self) -> GraphicalReportHandler
Disable syntax highlighting. This uses the
[crate::highlighters::BlankHighlighter] as a no-op highlighter.
pub fn with_link_display_text(
self,
text: impl Into<String>,
) -> GraphicalReportHandler
pub fn with_link_display_text( self, text: impl Into<String>, ) -> GraphicalReportHandler
Sets the display text for links.
Miette displays (link) if this option is not set.
§impl GraphicalReportHandler
impl GraphicalReportHandler
pub fn render_report(
&self,
f: &mut impl Write,
diagnostic: &dyn Diagnostic,
) -> Result<(), Error>
pub fn render_report( &self, f: &mut impl Write, diagnostic: &dyn Diagnostic, ) -> Result<(), Error>
Render a Diagnostic. This function is mostly internal and meant to
be called by the toplevel ReportHandler handler, but is made public
to make it easier (possible) to test in isolation from global state.
Trait Implementations§
§impl Clone for GraphicalReportHandler
impl Clone for GraphicalReportHandler
§fn clone(&self) -> GraphicalReportHandler
fn clone(&self) -> GraphicalReportHandler
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for GraphicalReportHandler
impl Debug for GraphicalReportHandler
§impl Default for GraphicalReportHandler
impl Default for GraphicalReportHandler
§fn default() -> GraphicalReportHandler
fn default() -> GraphicalReportHandler
§impl ReportHandler for GraphicalReportHandler
impl ReportHandler for GraphicalReportHandler
§fn debug(
&self,
diagnostic: &dyn Diagnostic,
f: &mut Formatter<'_>,
) -> Result<(), Error>
fn debug( &self, diagnostic: &dyn Diagnostic, f: &mut Formatter<'_>, ) -> Result<(), Error>
§fn display(
&self,
error: &(dyn Error + 'static),
f: &mut Formatter<'_>,
) -> Result<(), Error>
fn display( &self, error: &(dyn Error + 'static), f: &mut Formatter<'_>, ) -> Result<(), Error>
Display format§fn track_caller(&mut self, location: &'static Location<'static>)
fn track_caller(&mut self, location: &'static Location<'static>)
Auto Trait Implementations§
impl Freeze for GraphicalReportHandler
impl !RefUnwindSafe for GraphicalReportHandler
impl Send for GraphicalReportHandler
impl Sync for GraphicalReportHandler
impl Unpin for GraphicalReportHandler
impl UnsafeUnpin for GraphicalReportHandler
impl !UnwindSafe for GraphicalReportHandler
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more