Skip to main content

is_unknown_variant

Function is_unknown_variant 

Source
pub fn is_unknown_variant<M: TopLevelEnum>(frame: &[u8]) -> bool
Expand description

Classify a failed top-level-enum decode per ADR 013: return true iff the frame’s leading discriminant names a variant at or beyond M::VARIANT_COUNT — i.e. an unknown/unsupported variant the receiver must answer with UNSUPPORTED_MESSAGE (0x01) rather than MALFORMED_MESSAGE (0x03).

A frame that does not begin with a well-formed varint (empty, a non-terminating continuation run, or a 5th byte that overflows u32) is a genuine parse fault, so this returns false and the caller keeps the MALFORMED classification. Callers should only consult this after decode_message has actually failed; a valid in-range discriminant whose inner payload is malformed also stays MALFORMED (this returns false).