pub enum DecodeError {
Truncated,
UnsupportedMajorType(u8),
UnsupportedAdditionalInfo(u8),
UnsupportedAdditionalInfoEncoding(u8),
TrailingBytes,
InvalidUtf8,
UnrepresentableFloat,
NestingTooDeep,
}Variants§
Truncated
The buffer ended before a complete value could be read.
UnsupportedMajorType(u8)
Major type 6 (tags) — not part of macula’s wire format.
UnsupportedAdditionalInfo(u8)
A major-7 additional-info value with no meaning here (only 22 [null] and 25/26/27 [floats] are supported).
UnsupportedAdditionalInfoEncoding(u8)
Additional-info 28-31 on any major type — reserved, unused.
TrailingBytes
A single top-level value didn’t consume the whole buffer.
InvalidUtf8
A major-3 (text) value’s bytes were not valid UTF-8. The reference Erlang/Rust codec does not validate this on decode (it stores whatever bytes arrived); this port deliberately diverges and treats it as an error instead of losslessly carrying invalid UTF-8, since every real macula text value is ASCII/UTF-8 by construction and failing closed on malformed input from a peer is the safer default. Documented, not accidental.
UnrepresentableFloat
A half-float (binary16) with exponent 31 — NaN or infinity, which
has no representation as an ordinary f64 value here (matches
the reference decoder’s own behavior: no clause for it).
NestingTooDeep
Lists/maps nested more than MAX_NESTING_DEPTH levels deep.
Not part of the wire format’s own semantics — a defense against a
maliciously crafted frame: a list-of-one-list-of-one-list… can
encode extreme nesting in very few bytes (one byte per level),
and this decoder is plain recursive descent, so without a limit
a peer could crash the process with a stack overflow (not a
catchable panic) from a single frame well under
frame::MAX_FRAME_BYTES. No real macula wire value nests anywhere
close to this deep.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§fn clone(&self) -> DecodeError
fn clone(&self) -> DecodeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()