Skip to content

Struct envelope::ErrorBody

zaun_community_protocol::envelope::ErrorBody · Struct

pub struct ErrorBody { … }

An error object: code, message, and the code’s extra fields placed next to code. Build it with the constructors (one per ErrorCode, see errors.rs); they use fixed messages so no secret, connection detail, member key or other member’s data can reach the wire. The extras are boxed to keep Result<_, ErrorBody> small.

What went wrong; clients branch on this only.

Human-readable English text; informative, never branched on.

The code’s extra fields, serialised next to code (absent ones are omitted).

pub fn bad_request(field: Option<&str>) -> Self

BAD_REQUEST, naming the offending field path when known ("body.content"). The path names a schema field; never put a received value in it.

pub fn payload_too_large(limit: u64) -> Self

PAYLOAD_TOO_LARGE with the limit exceeded, in bytes or items.

pub fn unsupported_version(supported: VersionRange) -> Self

UNSUPPORTED_VERSION with the host’s supported range.

pub fn unsupported_feature<impl Into<Cow<'static, str>>>(feature: impl Into<Cow<'static, str>>) -> Self

UNSUPPORTED_FEATURE naming the feature ("attachments", "voice", a reserved command name). The name may be dynamic (BodyError::UnsupportedFeature) but must be a protocol name, never text taken from a secret or another member.

pub fn forbidden(missing: Option<u64>, reason: Option<Reason>) -> Self

FORBIDDEN, with the missing permission bits and the cause when known.

pub fn suspended(until: Option<u64>) -> Self

SUSPENDED, with the end of the suspension when it has one.

pub fn conflict(reason: Reason) -> Self

CONFLICT with its reason.

pub fn invalid_signature(object: &'static str) -> Self

INVALID_SIGNATURE naming the signed object ("descriptor", "delegation", …).

pub fn slowmode_active(retry_after_ms: u64) -> Self

SLOWMODE_ACTIVE (message as in the the protocol example).

pub fn rate_limited(retry_after_ms: u64, scope: RateScope, category: Option<RateCategory>) -> Self

RATE_LIMITED with the scope and, when one applies, the category.

pub fn timed_out(until: u64) -> Self

TIMED_OUT until the given time.

pub fn busy(retry_after_ms: u64) -> Self

BUSY: the host’s bounded queues are full.

pub fn resync_required_member() -> Self

RESYNC_REQUIRED for the member stream.

pub fn resync_required_channel(channel_id: ChannelId) -> Self

RESYNC_REQUIRED for a channel stream.

pub fn new(code: ErrorCode, message: &'static str) -> Self

A body with only code and message.

pub fn with_message(self, message: &'static str) -> Self

Replaces the default message with another fixed one.

pub const fn is_recorded(&self) -> bool

Whether a response carrying this error is stored as the idempotency record.

pub fn unsupported_command() -> Self

UNSUPPORTED_COMMAND: unknown type.

pub fn hello_required() -> Self

HELLO_REQUIRED: a command before a successful session.hello.

pub fn not_bound() -> Self

NOT_BOUND: a bound-only command on an unbound connection.

pub fn wrong_community() -> Self

WRONG_COMMUNITY: community_id differs from the binding.

pub fn host_not_authorized() -> Self

HOST_NOT_AUTHORIZED: no valid delegation for the community.

pub fn pending_approval() -> Self

PENDING_APPROVAL: the member is pending.

pub fn admission_closed() -> Self

ADMISSION_CLOSED (one code for every cause, so it is not an oracle).

pub fn not_found() -> Self

NOT_FOUND (missing and invisible are indistinguishable).

pub fn invite_invalid() -> Self

INVITE_INVALID (one code for every cause, so it is not an oracle).

pub fn banned() -> Self

BANNED: sent once, then the session ends.

pub fn internal() -> Self

INTERNAL: details are logged on the host, never sent.

Clone, Debug, Deserialize<'de>, Eq, PartialEq, Serialize, StructuralPartialEq

Full rustdoc page