Skip to main content

Diagnostic

Struct Diagnostic 

Source
pub struct Diagnostic {
    pub severity: Severity,
    pub rule: Rule,
    pub object: Option<Mrid>,
    pub class: Option<&'static str>,
    pub attribute: Option<&'static str>,
    pub source: Option<String>,
    pub position: Option<u64>,
    pub related_position: Option<u64>,
    pub message: String,
}
Expand description

A structured finding, usable by CI and tooling rather than only printable.

The object and attribute fields hold the identifier and the schema’s name, not rendered text, so callers can group or look up findings without parsing messages.

Fields§

§severity: Severity§rule: Rule§object: Option<Mrid>

Identifier of the object concerned, when the finding is object-scoped.

§class: Option<&'static str>

Class name of that object.

§attribute: Option<&'static str>

Qualified attribute name, when the finding is attribute-scoped.

§source: Option<String>

Source file the finding came from.

§position: Option<u64>

Byte offset in the source document, when the finding came from parsing.

An offset, not a line, because the reader streams; line_and_column converts. The reader records the start of the element concerned: its <.

§related_position: Option<u64>

Byte offset of an earlier occurrence the finding refers to, such as the first of two conflicting values.

§message: String

Implementations§

Source§

impl Diagnostic

Source

pub fn new( severity: Severity, rule: Rule, message: impl Into<String>, ) -> Diagnostic

Source

pub fn error(rule: Rule, message: impl Into<String>) -> Diagnostic

Source

pub fn warning(rule: Rule, message: impl Into<String>) -> Diagnostic

Source

pub fn info(rule: Rule, message: impl Into<String>) -> Diagnostic

Source

pub fn with_object(self, mrid: impl Into<Mrid>) -> Diagnostic

Source

pub fn with_class(self, class: &'static str) -> Diagnostic

Source

pub fn with_attribute(self, attr: &'static str) -> Diagnostic

Source

pub fn with_source(self, source: impl Into<String>) -> Diagnostic

Source

pub fn with_position(self, position: u64) -> Diagnostic

Record the byte offset in the source document the finding came from.

Record the byte offset of an earlier occurrence the finding refers to.

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostic

Source§

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

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

impl Display for Diagnostic

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Diagnostic

§

impl Freeze for Diagnostic
where *const str is !null: Freeze, PhantomData<str>: Freeze, &'static str: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Diagnostic

§

impl RefUnwindSafe for Diagnostic

§

impl Send for Diagnostic
where BoxRaw<str>: Send, &'static str: Send, RawVecInner: Send,

§

impl Sync for Diagnostic
where BoxRaw<str>: Sync, RawVecInner: Sync,

§

impl Unpin for Diagnostic
where Box<str>: Unpin, &'static str: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Diagnostic

§

impl UnwindSafe for Diagnostic
where BoxRaw<str>: UnwindSafe, &'static str: UnwindSafe, RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.