#[non_exhaustive]#[repr(u8)]pub enum NackReason {
BadMagic = 1,
VersionMismatch = 2,
BadHeaderCrc = 3,
PayloadTooLarge = 4,
BadPayloadCrc = 5,
InternalError = 6,
EmptyPayload = 7,
UnknownMessage = 8,
ReservedFlagsSet = 9,
BadBatchFraming = 11,
}Expand description
Re-export of weir_core::NackReason — the payload of ClientError::Nack.
Re-exported so consumers can match on the reason (e.g. to distinguish the
connection-closing Nacks) without taking a direct dependency on weir-core.
Reason byte carried as the first byte of every Nack message payload.
Wire values are fixed and must not change without a WIRE_VERSION bump.
VersionMismatch Nack payload format: [NackReason::VersionMismatch (0x02), daemon_wire_version (u8)].
The second byte lets the client produce a specific error:
“daemon is on wire protocol v1; this client is built against v2 — upgrade the daemon or downgrade the client.”
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BadMagic = 1
Frame did not start with the b"WEIR" magic.
VersionMismatch = 2
Frame’s version byte did not equal the daemon’s WIRE_VERSION. The Nack
payload’s second byte carries the daemon’s version (see above).
BadHeaderCrc = 3
Header CRC32 did not match the header bytes.
PayloadTooLarge = 4
Declared payload_len exceeded the daemon’s effective cap.
BadPayloadCrc = 5
Payload CRC32 did not match the payload bytes.
InternalError = 6
The daemon hit an internal error (e.g. queue saturation); transient.
EmptyPayload = 7
The push carried a zero-length payload, which the WAB cannot represent: an empty record’s length prefix is four zero bytes, identical to the end-of-records sentinel, so storing one would truncate the segment. Rejected at ingest.
UnknownMessage = 8
The frame’s header was structurally valid (magic, version, and header CRC
all passed) but carried a message_type or durability byte this daemon
does not recognise — a PERMANENT client protocol error (typically version
skew). Distinct from InternalError (a transient daemon-side condition
that keeps the connection open): the daemon closes the connection after
this Nack. Retrying the identical frame will not succeed (F25).
ReservedFlagsSet = 9
The frame’s header was structurally valid but set one or more bits in the
reserved flags byte, which must be zero in wire v1. A daemon rejects
such a frame rather than silently ignoring a flag it does not understand
(which could mean a producer believed a semantic flag took effect when it
did not). Permanent; the daemon closes the connection (F52).
BadBatchFraming = 11
A PushBatch body could not be parsed: bad batch version, zero records,
a record length that disagrees with the body, or trailing bytes.
0x0B, not 0x0A. 0x0A is this tree’s worked example of an
unassigned reason — a try_from test asserts it errors, a client test
asserts it surfaces as UnknownNack(0x0A), four polyglot clients branch
on >= 0x0A, and the frozen vector nack_reserved_reason IS 0x0A.
Assigning it would break a frozen vector, which the freeze forbids.
Implementations§
Source§impl NackReason
impl NackReason
Sourcepub fn as_metric_label(&self) -> &'static str
pub fn as_metric_label(&self) -> &'static str
The canonical snake_case metric-label string for this reason.
These strings match the daemon’s Prometheus reason label values exactly
(the nack_total{reason=...} series), so an ops consumer — an autoscaler,
an alerting rule, a dashboard — can map a NackReason it receives over the
wire to the metric label it must query, without hard-coding the strings.
Inverse of NackReason::from_metric_label.
use weir_core::NackReason;
assert_eq!(NackReason::PayloadTooLarge.as_metric_label(), "payload_too_large");Sourcepub fn from_metric_label(s: &str) -> Option<NackReason>
pub fn from_metric_label(s: &str) -> Option<NackReason>
Parses a snake_case metric label back into its NackReason, or None if
the string is not a known label. Inverse of
NackReason::as_metric_label.
use weir_core::NackReason;
assert_eq!(
NackReason::from_metric_label("payload_too_large"),
Some(NackReason::PayloadTooLarge),
);
assert_eq!(NackReason::from_metric_label("nope"), None);Trait Implementations§
Source§impl Clone for NackReason
impl Clone for NackReason
Source§fn clone(&self) -> NackReason
fn clone(&self) -> NackReason
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 NackReason
Source§impl Debug for NackReason
impl Debug for NackReason
Source§impl Display for NackReason
impl Display for NackReason
impl Eq for NackReason
Source§impl Error for NackReason
impl Error for NackReason
1.30.0 · 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()