Skip to main content

MessageError

Enum MessageError 

Source
#[non_exhaustive]
pub enum MessageError { BufferTooSmall, TooShort, InvalidMagic, UnsupportedVersion, InvalidMessageType, PayloadTooLarge, TruncatedField, InvalidUtf8, FieldTooLarge, EmptyCollection, InvalidFlags, TombstoneWithBody, }
Expand description

Errors that can occur when encoding or decoding a Peat-Lite message.

Marked #[non_exhaustive] so future protocol amendments can add variants without breaking exhaustive-match consumers.

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.
§

BufferTooSmall

Output buffer is too small for the encoded message.

§

TooShort

Input buffer is shorter than the minimum header size.

§

InvalidMagic

Magic bytes do not match.

§

UnsupportedVersion

Protocol version is not supported.

§

InvalidMessageType

Message type byte is not recognised.

§

PayloadTooLarge

Payload exceeds MAX_PAYLOAD_SIZE.

§

TruncatedField

A length-prefixed field declared more bytes than remain in the input — truncated wire encoding.

§

InvalidUtf8

A length-prefixed string field is not valid UTF-8. peat-lite declares collection names + document ids as UTF-8 by spec; non- UTF-8 bytes indicate corruption or a non-conforming sender.

§

FieldTooLarge

A length-prefixed field exceeded its declared maximum (collection over 255 bytes, doc_id or body over 65535 bytes). The wire format uses fixed-width length prefixes per field; oversized values must be rejected at encode time so receivers can trust the fixed widths.

§

EmptyCollection

A MessageType::Document envelope’s collection name was empty (coll_len = 0). Empty collection is structurally invalid — receivers can’t route the document. Distinct from Self::FieldTooLarge (which is for length-cap violations) and from Self::TruncatedField (which is for buffer-shorter- than-declared cases). Round-2 of peat-lite#26 introduced this to fix an asymmetric-variant trap where encoder and decoder reported the same condition with different error names.

§

InvalidFlags

A reserved or not-yet-implemented flag bit was set on a MessageType::Document envelope. Today’s encoder rejects any flag with reserved bits 2–7 set, and additionally bit 1 (DOC_FLAG_ENCRYPTED) which is reserved for a future per-document encryption layer not yet wired through. Lets us add features without older encoders silently shipping invalid frames.

§

TombstoneWithBody

MessageType::Document envelope had DOC_FLAG_TOMBSTONE set AND a non-empty body. Per the envelope spec, a tombstone is a deletion sentinel; carrying body bytes alongside it is a publisher contract violation that downstream consumers might process write-then-delete races against. Rejected at encode time so the bug doesn’t reach the wire.

Trait Implementations§

Source§

impl Clone for MessageError

Source§

fn clone(&self) -> MessageError

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 MessageError

Source§

impl Debug for MessageError

Source§

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

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

impl Eq for MessageError

Source§

impl PartialEq for MessageError

Source§

fn eq(&self, other: &MessageError) -> 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 MessageError

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, 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.