pub enum Fault<L = Profile<true, true, true>>where
L: LaneProfile,{
Denied(<L as LaneProfile>::Denied),
Transient(<L as LaneProfile>::Transient),
Fatal(<L as LaneProfile>::Fatal),
}Expand description
Fail minus the Rejected lane: what an operation that cannot reject
(nothing about it is the caller’s to correct) returns. Reads return
Fault<L>; writes return Fail<{Entity}ConstraintViolation, L> — the type
itself says whether a call can ever hand back a domain outcome.
Variants§
Denied(<L as LaneProfile>::Denied)
Transient(<L as LaneProfile>::Transient)
Fatal(<L as LaneProfile>::Fatal)
Implementations§
Source§impl Fault
impl Fault
Sourcepub fn classify(e: &(dyn Error + 'static)) -> Fault
pub fn classify(e: &(dyn Error + 'static)) -> Fault
Classify an erased error at a boundary that only has &(dyn Error + 'static) — e.g. &*boxed for a Box<dyn Error> that is not
Send/Sync and so cannot become a lane payload’s source
(Fatal’s and Transient’s sources are Arc<dyn Error + Send + Sync>, by design — see the crate README). No Send/Sync bound is
needed here: every step only ever borrows e. Call before the next
.await — the chain being walked may not be Send.
- A lane payload anywhere in the chain wins, carried through intact
— kind, context, and (now
Send/Sync, having been cloned out) its own original source. - Else, for each blessed foreign type whose
classify-*feature is enabled (sqlx::Error,serde_json::Error,reqwest::Error, in that order), the first one found anywhere in the chain is classified exactly as that feature’simpl Classifywould — with the error’s message ascontextin place of the source this function cannot move out of a shared reference. - Else
Fatal(FatalKind::Dependency), withmessage_chain(private) ascontext.
Rule 3 is a safety default, not a shrug: an error this function
cannot otherwise classify must still surface as something a boundary
pages on, never silently as nothing. A lane payload found by this
rule may itself be a Denied — narrowing it away, if the boundary
has no subject, is the caller’s explicit next step (see
Fault::narrow_denied).
Source§impl<L> Fault<L>where
L: LaneProfile,
impl<L> Fault<L>where
L: LaneProfile,
pub fn lane(&self) -> Lane
pub fn is_transient(&self) -> bool
pub fn is_fatal(&self) -> bool
pub fn is_denied(&self) -> bool
Sourcepub fn message(&self) -> String
pub fn message(&self) -> String
The operator-safe one-line text for this failure — exactly what
record writes to exception.message, for a boundary that must
persist it rather than (or as well as) record it. Transient/
Fatal: the whole source() chain joined with ": ". Denied: its
Display.
Sourcepub fn narrow_transient(
self,
attempts: u32,
) -> Fault<<L as LaneProfile>::WithoutTransient>
pub fn narrow_transient( self, attempts: u32, ) -> Fault<<L as LaneProfile>::WithoutTransient>
Consumes the Transient lane, yielding the same profile with its
transient slot disabled. attempts is what the retry loop counted; an
exhausted transient becomes Fatal(Exhausted) with the last transient
as its source.
Sourcepub fn narrow_denied(self) -> Fault<<L as LaneProfile>::WithoutDenied>
pub fn narrow_denied(self) -> Fault<<L as LaneProfile>::WithoutDenied>
Narrows away the Denied lane: a denial at a boundary with no
subject (code running as the system) becomes Fatal(Denied) with
the Denied as its source.
Source§impl<L> Fault<L>where
L: LaneProfile<Denied = Denied>,
Borrowed lane accessors. min_exhaustive_patterns lets a by-value match
name only the lanes a profile enables, but a borrowed match still demands an
arm for every variant. These accessors are the borrowed form, so no caller
ever has to write a match *never {} arm. Each is available only when the
profile enables that lane, so e.as_denied() on a no-denial profile is a
compile error rather than a permanent None.
impl<L> Fault<L>where
L: LaneProfile<Denied = Denied>,
Borrowed lane accessors. min_exhaustive_patterns lets a by-value match
name only the lanes a profile enables, but a borrowed match still demands an
arm for every variant. These accessors are the borrowed form, so no caller
ever has to write a match *never {} arm. Each is available only when the
profile enables that lane, so e.as_denied() on a no-denial profile is a
compile error rather than a permanent None.
Source§impl<L> Fault<L>where
L: LaneProfile<Transient = Transient>,
impl<L> Fault<L>where
L: LaneProfile<Transient = Transient>,
pub fn as_transient(&self) -> Option<&Transient>
pub fn is_congestion(&self) -> bool
Sourcepub fn is_contention(&self) -> bool
pub fn is_contention(&self) -> bool
See [TransientKind::is_contention].
Source§impl<L> Fault<L>where
L: LaneProfile<Fatal = Fatal>,
impl<L> Fault<L>where
L: LaneProfile<Fatal = Fatal>,
Source§impl<L> Fault<L>where
L: LaneProfile,
impl<L> Fault<L>where
L: LaneProfile,
pub fn widen<M>(self) -> Fault<M>where
M: LaneProfile,
<L as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>,
<L as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>,
<L as LaneProfile>::Fatal: Into<<M as LaneProfile>::Fatal>,
Trait Implementations§
Source§impl<L> Clone for Fault<L>where
L: Clone + LaneProfile,
<L as LaneProfile>::Denied: Clone,
<L as LaneProfile>::Transient: Clone,
<L as LaneProfile>::Fatal: Clone,
impl<L> Clone for Fault<L>where
L: Clone + LaneProfile,
<L as LaneProfile>::Denied: Clone,
<L as LaneProfile>::Transient: Clone,
<L as LaneProfile>::Fatal: Clone,
Source§impl<L> Debug for Fault<L>where
L: Debug + LaneProfile,
<L as LaneProfile>::Denied: Debug,
<L as LaneProfile>::Transient: Debug,
<L as LaneProfile>::Fatal: Debug,
impl<L> Debug for Fault<L>where
L: Debug + LaneProfile,
<L as LaneProfile>::Denied: Debug,
<L as LaneProfile>::Transient: Debug,
<L as LaneProfile>::Fatal: Debug,
Source§impl<L> Display for Fault<L>where
L: LaneProfile,
impl<L> Display for Fault<L>where
L: LaneProfile,
Source§impl<L> Error for Fault<L>where
L: LaneProfile,
impl<L> Error for Fault<L>where
L: LaneProfile,
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<L> From<!> for Fault<L>where
L: LaneProfile,
Infallible is what a disabled lane slot is, so a value proven never to
exist converts trivially — match e {}.
impl<L> From<!> for Fault<L>where
L: LaneProfile,
Infallible is what a disabled lane slot is, so a value proven never to
exist converts trivially — match e {}.
Source§impl<D, S, L> From<Fault<S>> for Fail<D, L>where
S: LaneProfile,
L: LaneProfile,
<S as LaneProfile>::Denied: Into<<L as LaneProfile>::Denied>,
<S as LaneProfile>::Transient: Into<<L as LaneProfile>::Transient>,
<S as LaneProfile>::Fatal: Into<<L as LaneProfile>::Fatal>,
The real blanket the Infallible encoding could not have: Fault<L> is not
Fail, so this does not overlap From<T> for T.
impl<D, S, L> From<Fault<S>> for Fail<D, L>where
S: LaneProfile,
L: LaneProfile,
<S as LaneProfile>::Denied: Into<<L as LaneProfile>::Denied>,
<S as LaneProfile>::Transient: Into<<L as LaneProfile>::Transient>,
<S as LaneProfile>::Fatal: Into<<L as LaneProfile>::Fatal>,
The real blanket the Infallible encoding could not have: Fault<L> is not
Fail, so this does not overlap From<T> for T.
Source§impl<W, M> From<W> for Fault<M>where
W: Classify<Rejected = !>,
M: LaneProfile,
<<W as Classify>::Lanes as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>,
<<W as Classify>::Lanes as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>,
<<W as Classify>::Lanes as LaneProfile>::Fatal: Into<<M as LaneProfile>::Fatal>,
? into a Fault: only for a wrapper that never rejects. A rejection or
a mixed wrapper entering a Fault function stays an explicit narrowing
(.map_err(Fail::narrow_rejected)), never a silent ?.
impl<W, M> From<W> for Fault<M>where
W: Classify<Rejected = !>,
M: LaneProfile,
<<W as Classify>::Lanes as LaneProfile>::Denied: Into<<M as LaneProfile>::Denied>,
<<W as Classify>::Lanes as LaneProfile>::Transient: Into<<M as LaneProfile>::Transient>,
<<W as Classify>::Lanes as LaneProfile>::Fatal: Into<<M as LaneProfile>::Fatal>,
? into a Fault: only for a wrapper that never rejects. A rejection or
a mixed wrapper entering a Fault function stays an explicit narrowing
(.map_err(Fail::narrow_rejected)), never a silent ?.
Source§impl<L> Laned for Fault<L>
impl<L> Laned for Fault<L>
type WithoutTransient = Fault<<L as LaneProfile>::WithoutTransient>
fn lane(&self) -> Lane
fn narrow_transient( self, attempts: u32, ) -> <Fault<L> as Laned>::WithoutTransient
Source§fn message(&self) -> String
fn message(&self) -> String
record writes to exception.message, for a boundary that must
persist it rather than (or as well as) record it. Transient/
Fatal: the whole source() chain joined with ": ". Denied: its
Display. Rejected: the rejection’s code, never its message
(display discipline — a rejection’s message may embed caller-supplied
input).fn is_transient(&self) -> bool
fn is_fatal(&self) -> bool
fn is_denied(&self) -> bool
Auto Trait Implementations§
impl<L> Freeze for Fault<L>where
<L as LaneProfile>::Denied: Freeze,
<L as LaneProfile>::Transient: Freeze,
<L as LaneProfile>::Fatal: Freeze,
impl<L> RefUnwindSafe for Fault<L>where
<L as LaneProfile>::Denied: RefUnwindSafe,
<L as LaneProfile>::Transient: RefUnwindSafe,
<L as LaneProfile>::Fatal: RefUnwindSafe,
impl<L> Send for Fault<L>where
<L as LaneProfile>::Denied: Send,
<L as LaneProfile>::Transient: Send,
<L as LaneProfile>::Fatal: Send,
impl<L> Sync for Fault<L>where
<L as LaneProfile>::Denied: Sync,
<L as LaneProfile>::Transient: Sync,
<L as LaneProfile>::Fatal: Sync,
impl<L> Unpin for Fault<L>where
<L as LaneProfile>::Denied: Unpin,
<L as LaneProfile>::Transient: Unpin,
<L as LaneProfile>::Fatal: Unpin,
impl<L> UnsafeUnpin for Fault<L>where
<L as LaneProfile>::Denied: UnsafeUnpin,
<L as LaneProfile>::Transient: UnsafeUnpin,
<L as LaneProfile>::Fatal: UnsafeUnpin,
impl<L> UnwindSafe for Fault<L>where
<L as LaneProfile>::Denied: UnwindSafe,
<L as LaneProfile>::Transient: UnwindSafe,
<L as LaneProfile>::Fatal: UnwindSafe,
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<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