Skip to main content

Diagnostic

Struct Diagnostic 

Source
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

Source

pub fn new( code: DiagnosticCode, severity: DiagnosticSeverity, message: impl Into<String>, ) -> Diagnostic

Create a finding carrying a code from an external producer.

Source

pub fn of( info: &'static DiagnosticInfo, message: impl Into<String>, ) -> Diagnostic

Create a finding from its registered identity and default severity.

Source

pub fn code(&self) -> &str

Source

pub fn registered_info(&self) -> Option<&'static DiagnosticInfo>

Source

pub fn stage(&self) -> Option<DiagnosticStage>

Source

pub const fn id(&self) -> Option<&DiagnosticId>

Source

pub const fn severity(&self) -> DiagnosticSeverity

Source

pub fn message(&self) -> &str

Source

pub fn target(&self) -> Option<&str>

Source

pub fn spans(&self) -> &[SourceSpan]

Source

pub fn related(&self) -> &[DiagnosticId]

Source

pub const fn details(&self) -> &Map<String, Value>

Source

pub fn with_id(self, id: DiagnosticId) -> Diagnostic

Source

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.

Source

pub fn with_severity(self, severity: DiagnosticSeverity) -> Diagnostic

Source

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.

Source

pub fn target_is_pointer(&self) -> bool

True when the target is a pointer the stored document can write as is.

Source

pub fn with_span(self, span: SourceSpan) -> Result<Diagnostic, Error>

Source

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.

Source

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.

Source

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.

Source

pub fn with_details( self, details: Map<String, Value>, ) -> Result<Diagnostic, Error>

Source

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.

Source

pub fn suggested_action(&self) -> Option<&str>

What a user can do about this finding.

Source

pub fn with_suggested_action(self, action: impl Into<String>) -> Diagnostic

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Diagnostic

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<(), Error>

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

impl<'de> Deserialize<'de> for Diagnostic

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Diagnostic, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Diagnostic

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Serialize for Diagnostic

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<DiagnosticWire> for Diagnostic

Source§

type Error = Error

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

fn try_from( wire: DiagnosticWire, ) -> Result<Diagnostic, <Diagnostic as TryFrom<DiagnosticWire>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V