Skip to content

Enum command::BodyError

zaun_community_protocol::command::BodyError · Enum

pub enum BodyError { … }

A body that cannot be accepted. Each variant maps to one error code of the protocol; the envelope layer adds request_id, the message text and the extra fields.

SPEC: the protocol lets an over-limit field be either BAD_REQUEST (“value out of range”) or PAYLOAD_TOO_LARGE (“an envelope or field exceeds the protocol”). This crate applies one rule: a text, byte string or list longer than a the protocol maximum is BodyError::PayloadTooLarge; every other violation (missing, ill-typed, below a minimum, numeric range, rule) is BodyError::BadRequest.

BAD_REQUEST{field?}: malformed, missing, ill-typed or out-of-range value.

UNSUPPORTED_COMMAND: unknown type, or a reserved namespace.

UNSUPPORTED_FEATURE{feature}: a known name or value not implemented in v1.

PAYLOAD_TOO_LARGE{limit}: a field longer than its the protocol maximum.

pub const fn code(&self) -> ErrorCode

The the protocol error code to answer with.

pub fn field(&self) -> Option<&str>

The field at fault, when one is known.

pub fn bad<impl Into<String>>(field: &str, detail: impl Into<String>) -> Self

BAD_REQUEST blaming field.

pub fn too_large(field: &str, limit: usize) -> Self

PAYLOAD_TOO_LARGE for field with limit.

pub fn unsupported(feature: &str) -> Self

UNSUPPORTED_FEATURE for feature.

Clone, Debug, Display, Eq, Error, PartialEq, StructuralPartialEq

Full rustdoc page