Function decode_header
pub fn decode_header(input: &[u8]) -> Result<(Header, &[u8]), Error>Expand description
Decode a v1 header from input.
Returns the parsed header and a slice of the payload bytes.
§Contract
- Accepts
header_len >= V1_HEADER_LENand ignores appended header bytes it does not understand. - Rejects unknown flag bits for deterministic behavior.
- Validates
header_len + payload_len <= SLOT_CAPACITY. - Returns a payload slice that borrows from
input.
§Errors
Returns Error::Truncated if input does not contain enough bytes for the declared header or
payload. Returns Error::BadMagic, Error::BadHeaderLen, Error::BadPayloadLen, or
Error::UnknownFlags if the envelope is structurally invalid.