pub struct Diagnostic { /* private fields */ }Expand description
One coded user facing finding.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(
code: DiagnosticCode,
severity: DiagnosticSeverity,
message: impl Into<String>,
) -> Self
pub fn new( code: DiagnosticCode, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Self
Create a finding carrying a code from an external producer.
Sourcepub fn of(info: &'static DiagnosticInfo, message: impl Into<String>) -> Self
pub fn of(info: &'static DiagnosticInfo, message: impl Into<String>) -> Self
Create a finding from its registered identity and default severity.
pub fn code(&self) -> &str
pub fn registered_info(&self) -> Option<&'static DiagnosticInfo>
pub fn stage(&self) -> Option<DiagnosticStage>
pub const fn id(&self) -> Option<&DiagnosticId>
pub const fn severity(&self) -> DiagnosticSeverity
pub fn message(&self) -> &str
pub fn target(&self) -> Option<&str>
pub fn spans(&self) -> &[SourceSpan]
pub const fn details(&self) -> &Map<String, Value>
pub fn with_id(self, id: DiagnosticId) -> Self
pub fn with_severity(self, severity: DiagnosticSeverity) -> Self
Sourcepub fn with_target(self, target: impl Into<String>) -> Result<Self, Error>
pub fn with_target(self, target: impl Into<String>) -> Result<Self, Error>
Name the element this finding is about.
A locator is identity, so it is stored complete or refused: a truncated RFC 6901 pointer names a different element, or none. An empty, oversized, or NUL-bearing locator is a visible error, and the caller decides whether to keep the finding without one.
Sourcepub fn target_is_pointer(&self) -> bool
pub fn target_is_pointer(&self) -> bool
True when the target is a pointer the stored document can write as is.
pub fn with_span(self, span: SourceSpan) -> Result<Self, Error>
Sourcepub fn insert_detail(
&mut self,
key: impl Into<String>,
value: Value,
) -> Result<(), Error>
pub fn insert_detail( &mut self, key: impl Into<String>, value: Value, ) -> Result<(), Error>
Add one detail entry to a finding already built, under the same key and count limits the decoder enforces.
Sourcepub fn clear_target(&mut self)
pub fn clear_target(&mut self)
Drop the target of a finding already built: the operation that calls this changed the value it pointed into, so the locator no longer identifies anything. Code, message, severity, and spans stay.
Sourcepub fn set_target(&mut self, target: impl Into<String>) -> Result<(), Error>
pub fn set_target(&mut self, target: impl Into<String>) -> Result<(), Error>
Replace the target of a finding already built. Same rule as
Diagnostic::with_target: the complete locator is stored, or the
call fails visibly.
pub fn with_details(self, details: Map<String, Value>) -> Result<Self, Error>
Sourcepub fn set_details(&mut self, details: Map<String, Value>) -> Result<(), Error>
pub fn set_details(&mut self, details: Map<String, Value>) -> Result<(), Error>
Replace the details of a finding already built, under the same key and count limits the decoder enforces.
Sourcepub fn suggested_action(&self) -> Option<&str>
pub fn suggested_action(&self) -> Option<&str>
What a user can do about this finding.
pub fn with_suggested_action(self, action: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more