Trait Diagnostic

Source
pub trait Diagnostic: Debug {
    // Required method
    fn message(&self) -> String;

    // Provided methods
    fn severity(&self) -> Severity { ... }
    fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { ... }
    fn source_code(&self) -> Option<Arc<dyn Source>> { ... }
    fn labels(&self) -> Option<Box<dyn Iterator<Item = Label> + '_>> { ... }
    fn causes(
        &self,
    ) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_> { ... }
    fn related(
        &self,
    ) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_> { ... }
    fn help(&self) -> Option<Box<dyn Iterator<Item = Help> + '_>> { ... }
}
Expand description

Represents a single diagnostic message, which can be pretty-printed into an intuitive and fancy error message.

Required Methods§

Source

fn message(&self) -> String

Defines which message to be raised to the user, when reported.

Provided Methods§

Source

fn severity(&self) -> Severity

Diagnostic severity level.

This may be used by the renderer to determine how to display the diagnostic or even halt the program, depending on the severity level.

Source

fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>

Unique diagnostic code, which can be used to look up more information about the error.

Source

fn source_code(&self) -> Option<Arc<dyn Source>>

Gets the source code which the diagnostic refers to.

This isn’t used if only defined by itself. It will only be used if one or more labels are defined without any source directly attached.

Source

fn labels(&self) -> Option<Box<dyn Iterator<Item = Label> + '_>>

Labels to attach to snippets of the source code.

Source

fn causes( &self, ) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_>

Any errors which were the underlying cause for the diagnostic to be raised.

Source

fn related( &self, ) -> Box<dyn Iterator<Item = &(dyn Diagnostic + Send + Sync)> + '_>

Any related errors, which can be used to provide additional information about the diagnostic.

Source

fn help(&self) -> Option<Box<dyn Iterator<Item = Help> + '_>>

Help messages, which can be used to provide additional information about the diagnostic.

Trait Implementations§

Source§

impl Display for Box<dyn Diagnostic + Send + Sync + 'static>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Box<dyn Error + Sync + Send>> for Box<dyn Diagnostic + Send + Sync>

Source§

fn from(err: Box<dyn Error + Send + Sync>) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Box<dyn Diagnostic + Send + Sync>

Source§

fn from(s: Error) -> Self

Converts to this type from the input type.
Source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + 'static>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + 'static>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: Diagnostic + Send + Sync + 'static> From<T> for Box<dyn Diagnostic + Send + Sync + 'static>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Box<dyn Diagnostic + Send + Sync>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Box<dyn Diagnostic + Send + Sync>

Implementors§