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 <.
Byte offset of an earlier occurrence the finding refers to, such as the first of two conflicting values.
message: StringImplementations§
Source§impl Diagnostic
impl Diagnostic
pub fn new( severity: Severity, rule: Rule, message: impl Into<String>, ) -> Diagnostic
pub fn error(rule: Rule, message: impl Into<String>) -> Diagnostic
pub fn warning(rule: Rule, message: impl Into<String>) -> Diagnostic
pub fn info(rule: Rule, message: impl Into<String>) -> Diagnostic
pub fn with_object(self, mrid: impl Into<Mrid>) -> Diagnostic
pub fn with_class(self, class: &'static str) -> Diagnostic
pub fn with_attribute(self, attr: &'static str) -> Diagnostic
pub fn with_source(self, source: impl Into<String>) -> Diagnostic
Sourcepub fn with_position(self, position: u64) -> Diagnostic
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.