pub enum BrainError {
Io(Error),
Frame(FrameError),
Cbor(CborError),
Protocol(String),
Server {
code: ErrorCodeWire,
category: ErrorCategoryWire,
message: String,
retry_after_ms: Option<u32>,
response: Box<ErrorResponse>,
},
VersionMismatch {
chosen: u8,
supported: Vec<u8>,
},
Closed,
Timeout(Duration),
}Expand description
A failure from any client operation.
Variants§
Io(Error)
Local socket I/O failed.
Frame(FrameError)
A frame off the wire failed to decode (bad magic / CRC / reserved bits / oversize). A frame error desynchronizes the byte stream, so the connection is no longer usable.
Cbor(CborError)
A frame’s CBOR payload failed to encode or decode.
Protocol(String)
The peer broke the protocol sequence — e.g. an unexpected opcode where the handshake expects WELCOME, or a response on an unknown stream.
Server
The server returned a structured ERROR frame in response to a request. The full payload is preserved for code/category branching.
Fields
code: ErrorCodeWireSpecific error code; branch on this for programmatic handling.
category: ErrorCategoryWireCoarse class of the failure, for deciding whether to retry at all.
response: Box<ErrorResponse>The full decoded ERROR payload, kept so no field is lost to this projection.
VersionMismatch
The server chose a wire version the client does not support. Versions
are u8 on the wire (HELLO supported_versions / WELCOME
chosen_version).
Fields
Closed
The peer closed the connection (read returned zero bytes).
Timeout(Duration)
An operation did not complete within its deadline.
Implementations§
Source§impl BrainError
impl BrainError
Sourcepub fn from_server(response: ErrorResponse) -> Self
pub fn from_server(response: ErrorResponse) -> Self
Build a BrainError::Server from a decoded ERROR payload.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the operation could plausibly succeed. A transient
transport drop or a resource-exhaustion / unavailable server verdict
is retryable; a malformed-input or auth verdict is not. Consumed by
crate::retry::with_retry.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The server-requested cool-off before retrying, when the ERROR carried a
retry_after_ms. The retry combinator prefers this over its own
backoff schedule.
Trait Implementations§
Source§impl Debug for BrainError
impl Debug for BrainError
Source§impl Display for BrainError
impl Display for BrainError
Source§impl Error for BrainError
impl Error for BrainError
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()