Skip to main content

NackReason

Enum NackReason 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

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");
Source

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

Source§

fn clone(&self) -> NackReason

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NackReason

Source§

impl Debug for NackReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for NackReason

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for NackReason

Source§

impl Error for NackReason

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for NackReason

Source§

fn eq(&self, other: &NackReason) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NackReason

Source§

impl TryFrom<u8> for NackReason

Source§

type Error = UnknownNackReason

The type returned in the event of a conversion error.
Source§

fn try_from(value: u8) -> Result<NackReason, <NackReason as TryFrom<u8>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.