#[non_exhaustive]pub enum ClientError {
Io(Error),
Nack(NackReason),
VersionMismatch {
daemon_version: u8,
},
UnknownNack(u8),
PayloadTooLarge {
len: usize,
limit: usize,
},
Protocol(String),
NoDefaultDurability,
EmptyPayload,
}Expand description
All errors that can be returned by WeirClient methods.
#[non_exhaustive]: the client error set may grow post-1.0 (it already gained
VersionMismatch during the 1.0 hardening), so downstream matches must carry
a wildcard arm and adding a variant later is not a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io(Error)
An I/O error on the underlying socket.
Nack(NackReason)
The daemon sent a Nack with a recognised reason.
VersionMismatch
The daemon rejected the frame because its wire version differs from the
client’s. Carries the daemon’s WIRE_VERSION (the second Nack-payload
byte) so the caller can report both sides and decide whether to upgrade
the daemon or downgrade the client.
UnknownNack(u8)
The daemon sent a Nack with an unrecognised reason byte.
PayloadTooLarge
The payload exceeds the protocol hard cap and was rejected locally,
before any bytes were sent. The daemon would always reject a payload this
large (and a large frame can race the daemon’s Nack-and-close, surfacing as
a bare broken-pipe), so the client rejects it up front with no round-trip.
A deployment’s configured max_payload_bytes may be lower than this cap; a
payload over that lower limit is reported by the daemon as
ClientError::Nack(NackReason::PayloadTooLarge).
Fields
limit: usizeThe protocol hard cap (weir_core::MAX_PAYLOAD_HARD_CAP).
Protocol(String)
The daemon’s response violated the wire protocol.
NoDefaultDurability
push_default was called but no default durability was set.
EmptyPayload
push was called with an empty payload, rejected locally before any bytes
are sent. An empty payload IS the WAB end-of-records sentinel, so the daemon
Nacks it (NackReason::EmptyPayload) and closes the connection; rejecting
up front keeps the connection usable, mirroring the local
PayloadTooLarge reject.
Implementations§
Source§impl ClientError
impl ClientError
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Whether the connection is still usable after this error.
- Recoverable (
true) — the connection is still usable: the error is a local or per-record rejection that does not poison the client. Retry a different payload, or continue, on the same client. - Non-recoverable (
false) — the connection is dead or in an indeterminate state: the error poisoned the client (set its internalpoisoned/closed_after_nackflag). Drop this client and reconnect; every subsequent call on it will fail fast (seeWeirClient::is_poisoned).
This is the stable way to branch on whether to reconnect: ClientError is
#[non_exhaustive], so an exhaustive match on its variants will not compile
downstream, and the variant set may grow post-1.0. Calling is_recoverable
(or checking WeirClient::is_poisoned after a failed call) keeps working
across additions.
The classification is kept in lock-step with the client’s poison logic: a
variant is recoverable iff producing it does not set the client’s
poisoned or closed_after_nack flag.
| Variant | Recoverable? | Why |
|---|---|---|
PayloadTooLarge | yes | local pre-send rejection; no bytes sent, connection untouched |
EmptyPayload | yes | local pre-send rejection; no bytes sent, connection untouched |
NoDefaultDurability | yes | local misconfiguration; returned before any I/O |
Nack(InternalError) | yes | transient daemon condition; the daemon keeps the connection open |
Nack(any other reason) | no | the daemon closes the connection after the Nack |
VersionMismatch | no | a Nack reason; the daemon closes the connection |
UnknownNack | no | a Nack reason; the daemon closes the connection |
Io | no | a socket read/write failure poisons the client |
Protocol | no | a malformed/aborted response poisons the client (also the “reconnect” guard error) |
Note: a server Nack(PayloadTooLarge) (a payload over the daemon’s
configured cap) is not recoverable — the daemon Nacks then closes the
connection — whereas the local PayloadTooLarge
error (a payload over the protocol hard cap, rejected before any bytes are
sent) is. They are distinct variants despite the shared name.
New #[non_exhaustive] variants default to non-recoverable (false):
“drop and reconnect” is the safe assumption for an error this build does not
yet understand.
Trait Implementations§
Source§impl Debug for ClientError
impl Debug for ClientError
Source§impl Display for ClientError
impl Display for ClientError
Source§impl Error for ClientError
impl Error for ClientError
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()