Skip to main content

HeaderParser

Trait HeaderParser 

Source
pub trait HeaderParser:
    PacketHeader
    + FromBytes
    + KnownLayout
    + Immutable
    + Unaligned {
    type Output<'a>
       where Self: 'a;

    // Required method
    fn into_view<'a>(header: &'a Self, options: &'a [u8]) -> Self::Output<'a>;

    // Provided method
    fn from_bytes<'a>(
        buf: &'a [u8],
    ) -> Result<(Self::Output<'a>, &'a [u8]), PacketHeaderError> { ... }
}

Required Associated Types§

Source

type Output<'a> where Self: 'a

The high-level view returned to the user. Can be &'a Self for fixed headers or a custom wrapper<’a> for variable ones.

Required Methods§

Source

fn into_view<'a>(header: &'a Self, options: &'a [u8]) -> Self::Output<'a>

Transform the raw struct and the options slice into the Output type.

Provided Methods§

Source

fn from_bytes<'a>( buf: &'a [u8], ) -> Result<(Self::Output<'a>, &'a [u8]), PacketHeaderError>

parse the network layer, ensuring validity and length

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§

Source§

impl HeaderParser for ArpHeader

Source§

impl HeaderParser for DhcpHeader

Source§

impl HeaderParser for Ether8021qHeader

Source§

impl HeaderParser for EtherHeader

Source§

impl HeaderParser for Icmp6Header

Source§

impl HeaderParser for IcmpHeader

Source§

type Output<'a> = &'a IcmpHeader

Source§

impl HeaderParser for Ipv4Header

Source§

impl HeaderParser for Ipv6Header

Source§

impl HeaderParser for NullHeader

Source§

type Output<'a> = &'a NullHeader

Source§

impl HeaderParser for SctpHeader

Source§

type Output<'a> = &'a SctpHeader

Source§

impl HeaderParser for SllHeader

Source§

type Output<'a> = &'a SllHeader

Source§

impl HeaderParser for Sllv2Header

Source§

impl HeaderParser for TcpHeader

Source§

impl HeaderParser for GeneveHeader

Source§

impl HeaderParser for GreHeader

Source§

impl HeaderParser for Gtpv1Header

Source§

impl HeaderParser for Gtpv2Header

Source§

impl HeaderParser for L2tpv2Header

Source§

impl HeaderParser for L2tpv3ControlHeader

Source§

impl HeaderParser for L2tpv3SessionHeader

Source§

impl HeaderParser for MplsLabel

Source§

type Output<'a> = &'a MplsLabel

Source§

impl HeaderParser for NvgreHeader

Source§

impl HeaderParser for PbbBTag

Source§

type Output<'a> = &'a PbbBTag

Source§

impl HeaderParser for PbbITag

Source§

type Output<'a> = &'a PbbITag

Source§

impl HeaderParser for PptpGreHeader

Source§

impl HeaderParser for SttHeader

Source§

type Output<'a> = &'a SttHeader

Source§

impl HeaderParser for SttTcpHeader

Source§

impl HeaderParser for TeredoAuthHeader

Source§

impl HeaderParser for TeredoHeader

Source§

impl HeaderParser for VxlanHeader

Source§

impl HeaderParser for UdpHeader

Source§

type Output<'a> = &'a UdpHeader