Skip to main content

ErrorBody

Struct ErrorBody 

Source
pub struct ErrorBody {
    pub code: ErrorCode,
    pub message: String,
    pub extras: Box<ErrorExtras>,
}
Expand description

An error object: code, message, and the code’s extra fields placed next to code (§7.2, §11). 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 (§11). The extras are boxed to keep Result<_, ErrorBody> small.

Fields§

§code: ErrorCode

What went wrong; clients branch on this only.

§message: String

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

§extras: Box<ErrorExtras>

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

Implementations§

Source§

impl ErrorBody

Source

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.

Source

pub fn payload_too_large(limit: u64) -> Self

PAYLOAD_TOO_LARGE with the limit exceeded, in bytes or items.

Source

pub fn unsupported_version(supported: VersionRange) -> Self

UNSUPPORTED_VERSION with the host’s supported range.

Source

pub fn unsupported_feature(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 (§11).

Source

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

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

Source

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

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

Source

pub fn conflict(reason: Reason) -> Self

CONFLICT with its reason.

Source

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

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

Source

pub fn slowmode_active(retry_after_ms: u64) -> Self

SLOWMODE_ACTIVE (message as in the §7.2 example).

Source

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.

Source

pub fn timed_out(until: u64) -> Self

TIMED_OUT until the given time.

Source

pub fn busy(retry_after_ms: u64) -> Self

BUSY: the host’s bounded queues are full.

Source

pub fn resync_required_member() -> Self

RESYNC_REQUIRED for the member stream.

Source

pub fn resync_required_channel(channel_id: ChannelId) -> Self

RESYNC_REQUIRED for a channel stream.

Source§

impl ErrorBody

Source

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

A body with only code and message.

Source

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

Replaces the default message with another fixed one.

Source

pub const fn is_recorded(&self) -> bool

Whether a response carrying this error is stored as the idempotency record (§7.3).

Source

pub fn unsupported_command() -> Self

UNSUPPORTED_COMMAND: unknown type.

Source

pub fn hello_required() -> Self

HELLO_REQUIRED: a command before a successful session.hello.

Source

pub fn not_bound() -> Self

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

Source

pub fn wrong_community() -> Self

WRONG_COMMUNITY: community_id differs from the binding.

Source

pub fn host_not_authorized() -> Self

HOST_NOT_AUTHORIZED: no valid delegation for the community.

Source

pub fn pending_approval() -> Self

PENDING_APPROVAL: the member is pending.

Source

pub fn admission_closed() -> Self

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

Source

pub fn not_found() -> Self

NOT_FOUND (missing and invisible are indistinguishable).

Source

pub fn invite_invalid() -> Self

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

Source

pub fn banned() -> Self

BANNED: sent once, then the session ends.

Source

pub fn internal() -> Self

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

Trait Implementations§

Source§

impl Clone for ErrorBody

Source§

fn clone(&self) -> ErrorBody

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 Debug for ErrorBody

Source§

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

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

impl<'de> Deserialize<'de> for ErrorBody

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ErrorBody

Source§

impl PartialEq for ErrorBody

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for ErrorBody

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ErrorBody

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.