Enum WireError
#[non_exhaustive]pub enum WireError {
UnsupportedFormatVersion {
found: u16,
supported: u16,
},
}Expand description
Why a wire-level decode was refused.
Separate from SyncError on purpose. That enum is
ADR-0026’s and describes how a peer exchange failed; a version refusal is a
decoding failure that happens before any exchange semantics apply. Folding
this in later is a phase-13 decision about the message set, and it supersedes
nothing to make it — whereas adding a variant to SyncError now would take
that decision inside an encoding change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedFormatVersion
The sender speaks a format version this build does not implement.
The whole message is refused; nothing inside it has been decoded. A receiver may park the bytes and retry after an upgrade, which is the reason this must be distinguishable from a malformed message — those bytes will never decode, and parking them is a leak.
Fields
supported: u16The version this build implements, i.e. FORMAT_VERSION.
Implementations§
§impl WireError
impl WireError
pub const UNSUPPORTED_FORMAT_VERSION: &'static str = "unsupported wire format version"
pub const UNSUPPORTED_FORMAT_VERSION: &'static str = "unsupported wire format version"
The stable text that marks a version refusal in a decoder’s error.
serde’s Deserialize has exactly one channel out — Error::custom,
which takes a Display and erases the type — so a typed WireError
cannot cross the boundary of Envelope’s Deserialize. What crosses
is this text, and it is public precisely so that “refused, park this”
stays distinguishable from “malformed, drop this” without callers
matching on a message they had to copy out of the source.
§It crosses serde_json, and it does not cross postcard
Measured by wire::rejects_an_unknown_format_version, which pins both
halves. postcard::Error is a fieldless enum, so its Error::custom
discards the Display it is given and every refusal arrives as
SerdeDeCustom — the text is dropped by the format, not by this module,
and no wording here could survive it. A postcard receiver gets its typed
answer the other way round: read the version off the front of the buffer
with postcard::take_from_bytes::<u16> and hand it to
check_format_version, which is the reason that function is public.
Trait Implementations§
impl Copy for WireError
impl Eq for WireError
§impl Error for WireError
impl Error for WireError
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()