#[non_exhaustive]pub enum Subsystem {
Storage,
Extract,
Validate,
Retrieve,
Consolidate,
Scope,
}Expand description
Coarse subsystem tag for a LunarisError — one classifying match, inside
the crate that owns the enum.
Four places classified LunarisError by variant independently: the
Prometheus kind label, the HTTP status map, and the Python and TypeScript
SDK error codes. Every one ended in a wildcard arm — not by carelessness,
but because LunarisError is #[non_exhaustive] and a downstream crate
has no choice. So the compiler could never flag a new variant going
unclassified, and when Scope was added all four silently began reporting
it as unknown. Two of them carried a claim of totality: a comment reading
“New variants in the future MUST extend this match”, and a test named
error_kind_maps_every_lunaris_error_variant. Writing the instruction down
did not make the next variant obey it.
#[non_exhaustive] does not apply inside the defining crate, so the match
in LunarisError::subsystem is exhaustiveness-checked for real: adding a
variant without tagging it fails to compile here. Consumers still write
their wildcard, but they can now walk Subsystem::ALL to prove their own
map is total — turning a silent “unknown” into a failing test.
let err = LunarisError::Scope(ScopeError::Invalid("bad:scope".into()));
assert_eq!(err.subsystem(), Subsystem::Scope);
assert_eq!(err.subsystem().label(), "scope"); // metrics / HTTP envelope
assert_eq!(err.subsystem().code(), "SCOPE"); // Python + TypeScript SDKsVariants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl Subsystem
impl Subsystem
Sourcepub const ALL: &'static [Subsystem]
pub const ALL: &'static [Subsystem]
Every subsystem, in declaration order. Generated from the same
list as LunarisError::subsystem, so it cannot fall behind
the enum the way a hand-written list does.
Sourcepub const fn label(self) -> &'static str
pub const fn label(self) -> &'static str
Lowercase tag — the Prometheus kind label and the error
field of the server’s JSON envelope.
Sourcepub const fn code(self) -> &'static str
pub const fn code(self) -> &'static str
Uppercase tag — the code the Python and TypeScript SDKs put
in front of the message so callers can branch without parsing.
Sourcepub fn sample_error(self) -> LunarisError
pub fn sample_error(self) -> LunarisError
A representative error of this subsystem.
Exists so a consumer that maps LunarisError to something of
its own — an HTTP status, an SDK code — can walk Self::ALL
and feed its mapper a real value for every subsystem, instead
of hand-listing the ones whoever wrote the test remembered.
Every such mapper needs a wildcard arm it cannot delete, so
this is the only way to prove the arm is unreachable.
Trait Implementations§
impl Copy for Subsystem
impl Eq for Subsystem
impl StructuralPartialEq for Subsystem
Auto Trait Implementations§
impl Freeze for Subsystem
impl RefUnwindSafe for Subsystem
impl Send for Subsystem
impl Sync for Subsystem
impl Unpin for Subsystem
impl UnsafeUnpin for Subsystem
impl UnwindSafe for Subsystem
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> 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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