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§
Source§impl GraphicalReportHandler
impl GraphicalReportHandler
Sourcepub fn new() -> GraphicalReportHandler
pub fn new() -> GraphicalReportHandler
Create a new GraphicalReportHandler
with the default
GraphicalTheme
. This will use both unicode characters and colors.
Sourcepub fn new_themed(theme: GraphicalTheme) -> GraphicalReportHandler
pub fn new_themed(theme: GraphicalTheme) -> GraphicalReportHandler
Create a new GraphicalReportHandler
with a given GraphicalTheme
.
Sourcepub fn tab_width(self, width: usize) -> GraphicalReportHandler
pub fn tab_width(self, width: usize) -> GraphicalReportHandler
Set the displayed tab width in spaces.
Sourcepub fn with_links(self, links: bool) -> GraphicalReportHandler
pub fn with_links(self, links: bool) -> GraphicalReportHandler
Whether to enable error code linkification using Diagnostic::url()
.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn with_theme(self, theme: GraphicalTheme) -> GraphicalReportHandler
pub fn with_theme(self, theme: GraphicalTheme) -> GraphicalReportHandler
Set a theme for this handler.
Sourcepub fn with_width(self, width: usize) -> GraphicalReportHandler
pub fn with_width(self, width: usize) -> GraphicalReportHandler
Sets the width to wrap the report at.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Source§impl GraphicalReportHandler
impl GraphicalReportHandler
Sourcepub 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§
Source§impl Clone for GraphicalReportHandler
impl Clone for GraphicalReportHandler
Source§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 moreSource§impl Debug for GraphicalReportHandler
impl Debug for GraphicalReportHandler
Source§impl Default for GraphicalReportHandler
impl Default for GraphicalReportHandler
Source§fn default() -> GraphicalReportHandler
fn default() -> GraphicalReportHandler
Source§impl ReportHandler for GraphicalReportHandler
impl ReportHandler for GraphicalReportHandler
Source§fn debug(
&self,
diagnostic: &dyn Diagnostic,
f: &mut Formatter<'_>,
) -> Result<(), Error>
fn debug( &self, diagnostic: &dyn Diagnostic, f: &mut Formatter<'_>, ) -> Result<(), Error>
Source§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
formatSource§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 !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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§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 moreSource§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