wire-decode
Source: crates/lvcs-net/src/wire/mod.rs.
/// Decode one envelope.
///
/// It does not check the signature ([`verify`]) or the kind: a kind
/// outside the `wire_kind` set ([`known_kind`] is `None`) is ignored by the
/// receiver, never rejected (design §10).
///
/// # Errors
///
/// [`WireError::TooLarge`] past `WIRE_MAX_BYTES` before anything is
/// decoded, [`WireError::UnknownMajor`] when its major version is not
/// `WIRE_MAJOR` (read first, whatever the rest holds), and
/// [`WireError::Malformed`] for anything else that is not a canonical CBOR
/// envelope.
pub fn decode(bytes: &[u8]) -> Result<Envelope, WireError> {