#[non_exhaustive]pub enum FailureClass {
InvalidRequest,
Transient,
PolicyRefusal,
BudgetExhausted,
Internal,
}Expand description
What kind of failure a task ended in.
#[non_exhaustive]: a later version may distinguish more, and a caller
that matches exhaustively today should keep compiling when it does.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidRequest
The request was wrong and will be wrong again. Never retry it.
Transient
Infrastructure did not cooperate — a timeout, a refused connection, a rate limit upstream. The same request may well succeed later.
PolicyRefusal
The agent declined on purpose: a safety filter, an entitlement, a policy. Retrying is not merely useless, it is the wrong response — this is the class that should reach a person.
BudgetExhausted
A bound was hit: a token budget, a deadline, a step limit. Retrying identically hits it again; retrying with more budget may not.
Internal
The agent broke, or classified nothing. Also what an unrecognised class from a newer peer reads as.
Implementations§
Source§impl FailureClass
impl FailureClass
Sourcepub const ALL: &'static [FailureClass]
pub const ALL: &'static [FailureClass]
Every class, for exhaustiveness in tests and for rendering a table.
A slice, not [Self; N]. The length was in the type, so adding the
sixth variant this enum is #[non_exhaustive] to allow would have
changed ALL’s type and broken every caller that bound it — the exact
break the attribute three lines up promises not to inflict.
Sourcepub fn from_wire(token: &str) -> FailureClass
pub fn from_wire(token: &str) -> FailureClass
Reads a wire token.
An unrecognised token is Internal, not None: a
peer classifying more finely than this build understands must not
have its failures become unreadable.
Sourcepub const fn is_retryable(self) -> bool
pub const fn is_retryable(self) -> bool
Whether retrying the identical request could succeed.
BudgetExhausted is not retryable by
this measure: the identical request hits the identical bound. It is
retryable with a larger budget, which is a different request.
Sourcepub const fn needs_human(self) -> bool
pub const fn needs_human(self) -> bool
Whether a person should see this rather than an automatic retry.
Trait Implementations§
Source§impl Clone for FailureClass
impl Clone for FailureClass
Source§fn clone(&self) -> FailureClass
fn clone(&self) -> FailureClass
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FailureClass
Source§impl Debug for FailureClass
impl Debug for FailureClass
Source§impl Display for FailureClass
impl Display for FailureClass
impl Eq for FailureClass
Source§impl From<ErrorCode> for FailureClass
impl From<ErrorCode> for FailureClass
Source§fn from(code: ErrorCode) -> FailureClass
fn from(code: ErrorCode) -> FailureClass
The class a protocol error maps to when an executor returned one and said nothing more.
The mapping is deliberately blunt: everything the caller could have
sent differently is InvalidRequest,
and everything else is Internal. Nothing
maps to Transient or
PolicyRefusal, because no
ErrorCode carries either meaning — an
agent that knows it hit a rate limit, or refused on policy, has to say
so itself, with set_error_class on the error it returns or by
emitting its own classified Failed status. Guessing Transient here would tell callers to retry
things that will never succeed.
Source§impl Hash for FailureClass
impl Hash for FailureClass
Source§impl PartialEq for FailureClass
impl PartialEq for FailureClass
impl StructuralPartialEq for FailureClass
Auto Trait Implementations§
impl Freeze for FailureClass
impl RefUnwindSafe for FailureClass
impl Send for FailureClass
impl Sync for FailureClass
impl Unpin for FailureClass
impl UnsafeUnpin for FailureClass
impl UnwindSafe for FailureClass
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request