Skip to main content

Layer

Trait Layer 

Source
pub trait Layer {
    // Required methods
    fn kind(&self) -> LayerKind;
    fn summary(&self, data: &[u8]) -> String;
    fn header_len(&self, data: &[u8]) -> usize;

    // Provided methods
    fn hashret(&self, _data: &[u8]) -> Vec<u8>  { ... }
    fn answers(&self, _data: &[u8], _other: &Self, _other_data: &[u8]) -> bool { ... }
    fn extract_padding<'a>(&self, data: &'a [u8]) -> (&'a [u8], &'a [u8]) { ... }
    fn field_names(&self) -> &'static [&'static str] { ... }
}
Expand description

Trait for types that can act as a network protocol layer.

This trait defines the core interface for all protocol layers, including methods for packet matching (hashret/answers) and padding extraction

Required Methods§

Source

fn kind(&self) -> LayerKind

Get the kind of this layer

Source

fn summary(&self, data: &[u8]) -> String

Get a human-readable summary of this layer

Source

fn header_len(&self, data: &[u8]) -> usize

Get the header length for this layer

Provided Methods§

Source

fn hashret(&self, _data: &[u8]) -> Vec<u8>

Compute a hash for packet matching.

Source

fn answers(&self, _data: &[u8], _other: &Self, _other_data: &[u8]) -> bool

Check if this packet answers another packet.

Source

fn extract_padding<'a>(&self, data: &'a [u8]) -> (&'a [u8], &'a [u8])

Extract padding from the packet.

Source

fn field_names(&self) -> &'static [&'static str]

Get the list of field names for this layer

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§