pub trait MessageBody: Sized {
    type B: ByteSlice;

    // Required methods
    fn parse(bytes: Self::B) -> ParseResult<Self>;
    fn len(&self) -> usize;
    fn bytes(&self) -> &[u8] ;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

MessageBody represents the parsed body of the ICMP packet.

  • For messages that expect no body, the MessageBody is of type EmptyMessage.
  • For NDP messages, the MessageBody is of the type ndp::Options.
  • For all other messages, the MessageBody will be of the type OriginalPacket, which is a thin wrapper around B.

Required Associated Types§

source

type B: ByteSlice

The underlying byteslice.

Required Methods§

source

fn parse(bytes: Self::B) -> ParseResult<Self>

Parse the MessageBody from the provided bytes.

source

fn len(&self) -> usize

The length of the underlying buffer.

source

fn bytes(&self) -> &[u8]

Return the underlying bytes.

Provided Methods§

source

fn is_empty(&self) -> bool

Is the body empty?

b.is_empty() is equivalent to b.len() == 0.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<B: ByteSlice, O: for<'a> OptionsImpl<'a>> MessageBody for Options<B, O>

§

type B = B

source§

fn parse(bytes: B) -> ParseResult<Options<B, O>>

source§

fn len(&self) -> usize

source§

fn bytes(&self) -> &[u8]

Implementors§

source§

impl<B: ByteSlice> MessageBody for Mldv1Body<B>

§

type B = B

source§

impl<B: ByteSlice> MessageBody for Mldv2ReportBody<B>

§

type B = B

source§

impl<B: ByteSlice> MessageBody for EmptyMessage<B>

§

type B = B

source§

impl<B: ByteSlice> MessageBody for OriginalPacket<B>

§

type B = B