pub struct DiagnosticDef {
code: DiagnosticCode,
slug: &'static str,
default_severity: Severity,
category: DiagnosticCategory,
owner: &'static str,
summary: &'static str,
}Expand description
Registry entry: one code, its slug, default severity, category, owner, summary.
Constructed only by define_codes!. Fields are read through the
accessors; there is no public constructor and no public field, so an
outside crate cannot forge a def that reuses an existing code with a
different slug or severity.
§Examples
use mos_core::{DiagnosticCategory, Severity, codes};
assert_eq!(codes::MOS0018.default_severity(), Severity::Notice);
assert_eq!(codes::MOS0018.category(), DiagnosticCategory::Text);
assert_eq!(codes::MOS0018.owner(), "mos-fonts");Fields§
§code: DiagnosticCode§slug: &'static str§default_severity: Severity§category: DiagnosticCategory§owner: &'static str§summary: &'static strImplementations§
Source§impl DiagnosticDef
impl DiagnosticDef
Sourcepub fn id(&self) -> String
pub fn id(&self) -> String
Canonical diagnostic identifier derived from the category and condition slug.
use mos_core::codes;
assert_eq!(codes::MOS0033.id(), "resolution.label-missing");Sourcepub fn documentation_url(&self) -> String
pub fn documentation_url(&self) -> String
Catalog URL with an explicit stable anchor for this rule.
Sourcepub const fn code(&self) -> DiagnosticCode
pub const fn code(&self) -> DiagnosticCode
The stable numeric compatibility alias.
§Examples
use mos_core::codes;
assert_eq!(codes::MOS0033.code().to_string(), "MOS0033");Sourcepub const fn slug(&self) -> &'static str
pub const fn slug(&self) -> &'static str
The machine-readable kebab-case handle (e.g. "label-duplicate").
§Examples
use mos_core::codes;
assert_eq!(codes::MOS0033.slug(), "label-missing");Sourcepub const fn default_severity(&self) -> Severity
pub const fn default_severity(&self) -> Severity
The severity this code carries unless overridden by future config.
§Examples
use mos_core::{Severity, codes};
assert_eq!(codes::MOS0033.default_severity(), Severity::Error);Sourcepub const fn category(&self) -> DiagnosticCategory
pub const fn category(&self) -> DiagnosticCategory
What kind of thing this code describes. Used by the catalog to group rules; never folded into identity.
§Examples
use mos_core::{DiagnosticCategory, codes};
assert_eq!(codes::MOS0033.category(), DiagnosticCategory::Resolution);Sourcepub const fn owner(&self) -> &'static str
pub const fn owner(&self) -> &'static str
The crate that owns the emit site(s).
§Examples
use mos_core::codes;
assert_eq!(codes::MOS0033.owner(), "mos-eval");Sourcepub const fn summary(&self) -> &'static str
pub const fn summary(&self) -> &'static str
One-line human summary, mirrored verbatim into the catalog.
§Examples
use mos_core::codes;
assert!(codes::MOS0033.summary().contains("@reference"));pub(crate) const fn new( code: DiagnosticCode, slug: &'static str, default_severity: Severity, category: DiagnosticCategory, owner: &'static str, summary: &'static str, ) -> Self
Trait Implementations§
Source§impl Clone for DiagnosticDef
impl Clone for DiagnosticDef
Source§fn clone(&self) -> DiagnosticDef
fn clone(&self) -> DiagnosticDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more