packet_formats::igmp

Trait MessageType

Source
pub trait MessageType<B> {
    type FixedHeader: Sized + Copy + Clone + FromBytes + IntoBytes + KnownLayout + Immutable + Unaligned + Debug;
    type VariableBody: Sized;
    type MaxRespTime: Sized + IgmpMaxRespCode + Debug;

    const TYPE: IgmpMessageType;

    // Required methods
    fn parse_body<BV: BufferView<B>>(
        header: &Self::FixedHeader,
        bytes: BV,
    ) -> Result<Self::VariableBody, ParseError>
       where B: SplitByteSlice;
    fn body_bytes(body: &Self::VariableBody) -> &[u8] 
       where B: SplitByteSlice;
}
Expand description

Trait specifying serialization behavior for IGMP messages.

IGMP messages are broken into 3 parts:

  • HeaderPrefix: common to all IGMP messages;
  • FixedHeader: A fixed part of the message following the HeaderPrefix;
  • VariableBody: A variable-length body;

MessageType specifies the types used for FixedHeader and VariableBody, HeaderPrefix is shared among all message types.

Required Associated Constants§

Source

const TYPE: IgmpMessageType

The type corresponding to this message type.

The value of the “type” field in the IGMP header corresponding to messages of this type.

Required Associated Types§

Source

type FixedHeader: Sized + Copy + Clone + FromBytes + IntoBytes + KnownLayout + Immutable + Unaligned + Debug

The fixed header type used for the message type.

These are the bytes immediately following the checksum bytes in an IGMP message. Most IGMP messages’ FixedHeader is an IPv4 address.

Source

type VariableBody: Sized

The variable-length body for the message type.

Source

type MaxRespTime: Sized + IgmpMaxRespCode + Debug

A type specializing how to parse the max_resp_code field in the HeaderPrefix.

Specifies how to transform Max Resp Code (transmitted value) into Max Resp Time (semantic meaning). Provides a single interface to deal with differences between IGMPv2 (RFC 2236) and IGMPv3 (RFC 3376).

The Max Resp Code field in HeaderPrefix only has meaning for IGMP Query messages, and should be set to zero for all other outgoing and ignored for all other incoming messages. For that case, an implementation of MaxRespTime for () is provided.

Required Methods§

Source

fn parse_body<BV: BufferView<B>>( header: &Self::FixedHeader, bytes: BV, ) -> Result<Self::VariableBody, ParseError>
where B: SplitByteSlice,

Parses the variable body part of the IGMP message.

Source

fn body_bytes(body: &Self::VariableBody) -> &[u8]
where B: SplitByteSlice,

Retrieves the underlying bytes of VariableBody.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§