Skip to main content

TopLevelEnum

Trait TopLevelEnum 

Source
pub trait TopLevelEnum {
    const VARIANT_COUNT: u32;
}
Expand description

A top-level ALPN protocol enum (one per ALPN — crate::ProbeMessage, crate::ClientMessage, crate::DhtMessage). Serialized as the outermost postcard value in a frame, so its variant discriminant is the frame’s leading varint.

Implementors expose their declared-variant count so the framing layer can tell an unknown discriminant (a variant this build does not know — ADR 013 UNSUPPORTED_MESSAGE, 0x01) apart from a genuine parse fault (MALFORMED_MESSAGE, 0x03) after a failed decode_message.

Required Associated Constants§

Source

const VARIANT_COUNT: u32

Number of declared variants. Postcard assigns discriminants 0..VARIANT_COUNT in declaration order, so any leading discriminant >= VARIANT_COUNT names a variant this build does not know.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§