pub struct Code { /* private fields */ }Expand description
A stable diagnostic code, rendered as MOLFRAME-E1103 or MOLFRAME-W3011.
§Examples
use molframe_core::Code;
assert_eq!(Code::E1103.to_string(), "MOLFRAME-E1103");
assert_eq!(Code::E1103.cause(), "loop_ row count is not a multiple of the column count");
assert!(!Code::E1103.remedy().is_empty());Implementations§
Source§impl Code
impl Code
Sourcepub const fn new(kind: Kind, number: u16) -> Self
pub const fn new(kind: Kind, number: u16) -> Self
Creates a code from its kind and number.
Prefer the associated constants; this exists so the registry can be declared as data.
Sourcepub const fn class(self) -> Class
pub const fn class(self) -> Class
The class this code belongs to, taken from its leading digit.
Sourcepub fn severity(self) -> Severity
pub fn severity(self) -> Severity
The registered severity, or Severity::Breaking for a code that is not
in the registry.
An unregistered code can only arise from a programming mistake, so the conservative reading is the right one.
Sourcepub fn remedy(self) -> &'static str
pub fn remedy(self) -> &'static str
What to do about it.
Every registered code has one. A diagnostic a user cannot act on is an incomplete diagnostic, so the remedy is part of the registry rather than something each call site is trusted to remember.
Sourcepub fn is_registered(self) -> bool
pub fn is_registered(self) -> bool
Returns true when this code is present in the registry.
Sourcepub fn registered() -> impl Iterator<Item = Self>
pub fn registered() -> impl Iterator<Item = Self>
Every registered code, ordered by kind and then number.
Source§impl Code
impl Code
Sourcepub const E5005: Self
pub const E5005: Self
cutoff exceeds half the minimum box dimension under the minimum image convention
Sourcepub const W3202: Self
pub const W3202: Self
observed atoms are inconsistent with the component definition; file connectivity was used
Trait Implementations§
impl Copy for Code
impl Eq for Code
Source§impl Ord for Code
impl Ord for Code
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Code
impl PartialOrd for Code
impl StructuralPartialEq for Code
Auto Trait Implementations§
impl Freeze for Code
impl RefUnwindSafe for Code
impl Send for Code
impl Sync for Code
impl Unpin for Code
impl UnsafeUnpin for Code
impl UnwindSafe for Code
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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