pub enum DecodeError {
UnexpectedEof {
needed: usize,
remaining: usize,
},
InvalidBool(u8),
InvalidUtf8,
LengthOverflow {
length: usize,
limit: usize,
},
}Expand description
A byte stream that does not satisfy the Cyclone Specification.
The Specification (RFC-0002 §10) names the error conditions but not the way an implementation reports them. This runtime reports them as values.
| Variant | Condition on the byte stream |
|---|---|
UnexpectedEof | fewer bytes remain than the value requires |
InvalidBool | a bool byte that is neither 0x00 nor 0x01 |
InvalidUtf8 | a String byte region that is not valid UTF-8 |
LengthOverflow | a length/count field beyond the configured limit |
InvalidEnum is deliberately absent: the set of valid values of an enum is
schema knowledge, so validating it belongs to the generated codec, not to a
runtime that knows nothing about schemas.
Variants§
UnexpectedEof
Fewer bytes remain in the buffer than the value being read requires.
Fields
InvalidBool(u8)
A bool was encoded as a byte other than 0x00 or 0x01.
A conforming decoder MUST NOT read this as “non-zero means true” (RFC-0002 §2.4). The offending byte is carried for diagnostics.
InvalidUtf8
The byte region of a String is not valid UTF-8 (RFC-0002 §3).
LengthOverflow
A length or count field exceeded the configured Limits.
This is the configurable, non-normative guard of RFC-0002 §12. The
normative check - a length larger than the bytes actually remaining -
surfaces as UnexpectedEof; both are applied,
and both reject before any memory is allocated.
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()