pub struct Diagnostic { /* private fields */ }Expand description
The common module records and containers. These explicit facade exports keep ordinary callers out of the component crate paths. One coded user facing finding.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(
code: DiagnosticCode,
severity: DiagnosticSeverity,
message: impl Into<String>,
) -> Diagnostic
pub fn new( code: DiagnosticCode, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Diagnostic
Create a finding carrying a code from an external producer.
Sourcepub fn of(
info: &'static DiagnosticInfo,
message: impl Into<String>,
) -> Diagnostic
pub fn of( info: &'static DiagnosticInfo, message: impl Into<String>, ) -> Diagnostic
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) -> Diagnostic
Sourcepub fn with_code(self, info: &'static DiagnosticInfo) -> Diagnostic
pub fn with_code(self, info: &'static DiagnosticInfo) -> Diagnostic
The same finding under another registered code. A writer that forwards a sibling writer’s findings gives them its own family this way.
pub fn with_severity(self, severity: DiagnosticSeverity) -> Diagnostic
Sourcepub fn with_target(self, target: impl Into<String>) -> Result<Diagnostic, Error>
pub fn with_target(self, target: impl Into<String>) -> Result<Diagnostic, 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<Diagnostic, 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<Diagnostic, 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>) -> Diagnostic
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 moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Diagnostic, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Diagnostic, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
Source§fn eq(&self, other: &Diagnostic) -> bool
fn eq(&self, other: &Diagnostic) -> bool
self and other values to be equal, and is used by ==.