Trait Classify
pub trait Classify {
// Required method
fn class(&self) -> FailureClass;
}Expand description
An error that states its FailureClass.
The class is a function of the error alone (SY-36): the same value always answers the same, whatever was retried before it or whichever batch carried it. Only the adapter that produced an error can say which class it is, so the adapter implements this and a runner never infers it.
§Examples
use happenstance_sync::{Classify, FailureClass};
#[derive(Debug)]
enum HttpError {
Status(u16),
Timeout,
}
impl Classify for HttpError {
fn class(&self) -> FailureClass {
match self {
Self::Status(401 | 403) => FailureClass::Stop,
Self::Status(413) => FailureClass::Split,
Self::Status(_) | Self::Timeout => FailureClass::Transient,
}
}
}
assert_eq!(HttpError::Status(413).class(), FailureClass::Split);
assert_eq!(HttpError::Timeout.class(), FailureClass::Transient);Required Methods§
fn class(&self) -> FailureClass
fn class(&self) -> FailureClass
The remedy this failure calls for.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl Classify for Infallible
A failure that cannot happen has no class to state, and needs none: no
value of it exists. It is here so a stage that never fails, such as the
Accept rule, still meets a Classify bound, and
so the errors that carry such a stage default to it.
impl Classify for Infallible
A failure that cannot happen has no class to state, and needs none: no
value of it exists. It is here so a stage that never fails, such as the
Accept rule, still meets a Classify bound, and
so the errors that carry such a stage default to it.
fn class(&self) -> FailureClass
§impl Classify for MemoryStoreError
Available on crate feature memory only.MemoryStoreError is uninhabited, so it states no class at all; the impl
exists because IngestStore::Error is bound
on Classify.
impl Classify for MemoryStoreError
memory only.MemoryStoreError is uninhabited, so it states no class at all; the impl
exists because IngestStore::Error is bound
on Classify.
fn class(&self) -> FailureClass
Implementors§
impl Classify for CodecError
impl Classify for ForeignToken
impl Classify for GroupOrderError
impl Classify for MemoryPeerError
memory only.impl Classify for SyncError
The runner’s own failures state a class too, so a runner handles them and a peer’s through one path (ADR-0026 §2.4).
impl<E: Classify> Classify for IngestError<E>
Each arm’s class is fixed by the arm, except Store,
which asks the adapter’s error. So the class is a function of the value
alone (SY-36).
impl<E: Classify> Classify for RemoteError<E>
The transport’s and the codec’s arms ask their errors; the limit arms are
fixed by the arm, as StorePeerError’s are (SY-36).
impl<P: Classify, R: Classify, I: Classify, A: Classify> Classify for StepError<P, R, I, A>
impl<R: Classify, W: Classify, A: Classify> Classify for ServeError<R, W, A>
impl<R: Classify, W: Classify, A: Classify> Classify for StorePeerError<R, W, A>
The store’s arms ask the store’s error, the rule’s arm the rule’s; the limit arms are fixed by the arm (SY-36).