[][src]Struct show_my_errors::AnnotationList

pub struct AnnotationList<'a> { /* fields omitted */ }

List of annotations applied to some input string. Doesn't owns string, so has a limited lifetime.

Methods

impl<'a> AnnotationList<'a>[src]

pub fn new(filename: impl AsRef<str>, string: &'a str) -> Self[src]

Create an annotation list from string. filename is used only to format messages, so corresponding file doesn't need to exist.

pub fn add(&mut self, annotation: Annotation) -> Result<&mut Self>[src]

Add an Annotation to list. You may also use .info(), .warning() and .error() methods.

pub fn info(
    &mut self,
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<&mut Self>
[src]

Add an Severity::Info annotation to list. See Annotation::new docs for details

pub fn warning(
    &mut self,
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<&mut Self>
[src]

Add an Severity::Warning annotation to list. See Annotation::new docs for details

pub fn error(
    &mut self,
    range: Range<usize>,
    header: impl AnnotationText,
    text: impl AnnotationText
) -> Result<&mut Self>
[src]

Add an Severity::Error annotation to list. See Annotation::new docs for details

pub fn show<W: Write + WriteColor>(
    &self,
    stream: W,
    stylesheet: &Stylesheet
) -> Result<()>
[src]

Print an error message to stream using given stylesheet. If your stream implements Write, but not WriteColor, consider wrapping it into termcolor::Ansi or termcolor::NoColor.

This method uses no buffering, so you probably want to pass termcolor::Buffer to it rather than raw stream.

If you want to just print message to stdout/stderr, consider using .print_stdout() or .print_stderr() instead.

pub fn show_stdout(&self, stylesheet: &Stylesheet) -> Result<()>[src]

Print error message to stdout. Output will be colorized if stdout is a TTY

pub fn show_stderr(&self, stylesheet: &Stylesheet) -> Result<()>[src]

Print error message to stderr. Output will be colorized if stderr is a TTY

pub fn to_bytes(&self) -> Result<Vec<u8>>[src]

"Print" monochrome message to Vec<u8>

pub fn to_ansi_bytes(&self, stylesheet: &Stylesheet) -> Result<Vec<u8>>[src]

"Print" message to Vec<u8>, colorizing it using ANSI escape codes

pub fn to_string(&self) -> Result<String>[src]

"Print" monochrome message to String

Panics

Panics if message cannot be converted to UTF-8

pub fn to_ansi_string(&self, stylesheet: &Stylesheet) -> Result<String>[src]

"Print" message to String, colorizing it using ANSI escape codes

Panics

Panics if message cannot be converted to UTF-8

Trait Implementations

impl<'a> Debug for AnnotationList<'a>[src]

impl<'a> Eq for AnnotationList<'a>[src]

impl<'a> PartialEq<AnnotationList<'a>> for AnnotationList<'a>[src]

impl<'a> StructuralEq for AnnotationList<'a>[src]

impl<'a> StructuralPartialEq for AnnotationList<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for AnnotationList<'a>

impl<'a> Send for AnnotationList<'a>

impl<'a> Sync for AnnotationList<'a>

impl<'a> Unpin for AnnotationList<'a>

impl<'a> UnwindSafe for AnnotationList<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.