Skip to main content

Diagnostic

Struct Diagnostic 

Source
pub struct Diagnostic { /* private fields */ }
Expand description

One finding about the data.

A finding always has a code, and through the code always has a cause and a remedy — neither is something a call site can forget to supply. The message is optional and defaults to the code’s registered cause, so raising a finding that needs no elaboration allocates nothing.

§Examples

use molframe_core::{Code, Diagnostic, Severity};

let finding = Diagnostic::new(Code::W3203).in_category("atom_site").at_row(17);
assert_eq!(finding.severity(), Severity::Loose);
assert_eq!(finding.message(), "element inferred from the atom name");
assert!(!finding.remedy().is_empty());

Implementations§

Source§

impl Diagnostic

Source

pub fn retained_bytes(&self) -> usize

Heap bytes retained by this occurrence’s owned details.

Source

pub fn new(code: Code) -> Self

Creates a finding carrying the code’s registered severity and cause.

Source

pub fn with_message(self, message: impl Into<Box<str>>) -> Self

Replaces the message with one describing this occurrence.

Use it when the specifics matter; leave it alone when the registered cause already says everything there is to say.

Source

pub const fn with_severity(self, severity: Severity) -> Self

Overrides the severity for this occurrence.

The registry decides severity in general. This exists for the cases where the same code is genuinely worse in one context than another.

Source

pub fn at(self, span: ByteSpan) -> Self

Records where in the source this finding was raised.

Source

pub fn in_category(self, category: impl Into<Box<str>>) -> Self

Records the category this finding concerns.

Source

pub fn about_field(self, field: impl Into<Box<str>>) -> Self

Records the item this finding concerns.

Source

pub const fn at_row(self, row: u64) -> Self

Records the row this finding concerns.

Source

pub fn with_context( self, label: &'static str, value: impl Into<Box<str>>, ) -> Self

Attaches a labelled detail.

Source

pub const fn code(&self) -> Code

The stable code.

Source

pub const fn severity(&self) -> Severity

How bad this finding is.

Source

pub fn message(&self) -> &str

What happened.

Source

pub fn remedy(&self) -> &'static str

What to do about it.

Source

pub fn span(&self) -> Option<ByteSpan>

Where in the source this was raised, if a position was known.

Source

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

The category this concerns, if any.

Source

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

The item this concerns, if any.

Source

pub const fn row(&self) -> Option<u64>

The row this concerns, if any.

Source

pub fn context(&self) -> &[ContextItem]

The labelled details attached to this finding.

Source

pub const fn is_error(&self, strictness: Strictness) -> bool

Returns true when this finding is an error at the given strictness.

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

impl Eq for Diagnostic

Source§

impl Extend<Diagnostic> for Diagnostics

Source§

fn extend<T: IntoIterator<Item = Diagnostic>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&!> for Diagnostic

Source§

fn from(never: &Infallible) -> Self

An error that cannot be constructed has no code to name.

Source§

impl From<&ContextError> for Diagnostic

Source§

fn from(_error: &ContextError) -> Self

Converts to this type from the input type.
Source§

impl From<&Diagnostic> for Diagnostic

Source§

fn from(diagnostic: &Diagnostic) -> Self

A finding is already a diagnostic; kernels that fail with one convert by copy.

Source§

impl From<&MemoryBudgetError> for Diagnostic

Source§

fn from(_error: &MemoryBudgetError) -> Self

Converts to this type from the input type.
Source§

impl From<&PolicyParseError> for Diagnostic

Source§

fn from(_error: &PolicyParseError) -> Self

Converts to this type from the input type.
Source§

impl From<&StructureBatchError> for Diagnostic

Source§

fn from(error: &StructureBatchError) -> Self

A wrapped diagnostic is returned as it is, so its code, remedy and span survive; the rest name the kind of limit that stopped the read.

Source§

impl From<ContextError> for Diagnostic

Source§

fn from(value: ContextError) -> Self

Converts to this type from the input type.
Source§

impl From<Diagnostic> for Findings

Source§

fn from(finding: Diagnostic) -> Self

Converts to this type from the input type.
Source§

impl From<Diagnostic> for StructureBatchError

Source§

fn from(error: Diagnostic) -> Self

Converts to this type from the input type.
Source§

impl From<MemoryBudgetError> for Diagnostic

Source§

fn from(value: MemoryBudgetError) -> Self

Converts to this type from the input type.
Source§

impl From<PolicyParseError> for Diagnostic

Source§

fn from(value: PolicyParseError) -> Self

Converts to this type from the input type.
Source§

impl From<StructureBatchError> for Diagnostic

Source§

fn from(error: StructureBatchError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Diagnostic

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Diagnostic

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> 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.