pub trait MessageBody: Sized {
type B: SplitByteSlice;
// Required methods
fn parse(bytes: Self::B) -> ParseResult<Self>;
fn len(&self) -> usize;
fn bytes(&self) -> (&[u8], Option<&[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 typeEmptyMessage
. - For NDP messages, the
MessageBody
is of the typendp::Options
. - For all other messages, the
MessageBody
will be of the typeOriginalPacket
, which is a thin wrapper aroundB
.
Required Associated Types§
Required Methods§
Sourcefn parse(bytes: Self::B) -> ParseResult<Self>
fn parse(bytes: Self::B) -> ParseResult<Self>
Parse the MessageBody from the provided bytes.
Sourcefn bytes(&self) -> (&[u8], Option<&[u8]>)
fn bytes(&self) -> (&[u8], Option<&[u8]>)
Return the underlying bytes.
Not all ICMP messages have a fixed size, some messages like MLDv2 Query or MLDv2 Report (RFC 3810 section 5.1 and RFC 3810 section 5.2) contain a fixed amount of information followed by a variable amount of records. The first value returned contains the fixed size part, while the second value contains the records for the messages that support them, more precisely, the second value is None if the message does not have a variable part, otherwise it will contain the serialized list of records.
Provided Methods§
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.