pub struct LayerStack { /* private fields */ }Expand description
A stack of protocol layers that can be combined into a packet.
The stack maintains the order of layers and automatically applies bindings when building the final packet.
Implementations§
Source§impl LayerStack
impl LayerStack
Sourcepub fn push(self, layer: LayerStackEntry) -> Self
pub fn push(self, layer: LayerStackEntry) -> Self
Push a new layer onto the stack.
Layers are stacked from bottom (first) to top (last).
Sourcepub fn add(&mut self, layer: LayerStackEntry)
pub fn add(&mut self, layer: LayerStackEntry)
Add a layer to the stack (mutable version).
Sourcepub fn stack(self, other: LayerStack) -> Self
pub fn stack(self, other: LayerStack) -> Self
Stack another LayerStack on top of this one.
This is the implementation of the / operator.
Sourcepub fn layers(&self) -> &[LayerStackEntry]
pub fn layers(&self) -> &[LayerStackEntry]
Get the layers in the stack.
Sourcepub fn build(&self) -> Vec<u8> ⓘ
pub fn build(&self) -> Vec<u8> ⓘ
Build the stacked layers into raw bytes.
This method:
- Builds each layer
- Applies bindings (e.g., sets Ethernet type when IP is stacked on top)
- Concatenates all layer bytes
- Recalculates checksums and lengths where applicable
Sourcepub fn build_packet(&self) -> Packet
pub fn build_packet(&self) -> Packet
Build the stack into a Packet.
Trait Implementations§
Source§impl Clone for LayerStack
impl Clone for LayerStack
Source§fn clone(&self) -> LayerStack
fn clone(&self) -> LayerStack
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LayerStack
impl Debug for LayerStack
Source§impl Default for LayerStack
impl Default for LayerStack
Source§fn default() -> LayerStack
fn default() -> LayerStack
Returns the “default value” for a type. Read more
Source§impl Div<LayerStackEntry> for LayerStack
impl Div<LayerStackEntry> for LayerStack
Source§type Output = LayerStack
type Output = LayerStack
The resulting type after applying the
/ operator.Source§impl Div for LayerStack
impl Div for LayerStack
Source§type Output = LayerStack
type Output = LayerStack
The resulting type after applying the
/ operator.Source§impl From<ArpBuilder> for LayerStack
impl From<ArpBuilder> for LayerStack
Source§fn from(builder: ArpBuilder) -> Self
fn from(builder: ArpBuilder) -> Self
Converts to this type from the input type.
Source§impl From<DnsBuilder> for LayerStack
impl From<DnsBuilder> for LayerStack
Source§fn from(builder: DnsBuilder) -> Self
fn from(builder: DnsBuilder) -> Self
Converts to this type from the input type.
Source§impl From<EthernetBuilder> for LayerStack
impl From<EthernetBuilder> for LayerStack
Source§fn from(builder: EthernetBuilder) -> Self
fn from(builder: EthernetBuilder) -> Self
Converts to this type from the input type.
Source§impl From<Icmpv6Builder> for LayerStack
impl From<Icmpv6Builder> for LayerStack
Source§fn from(builder: Icmpv6Builder) -> Self
fn from(builder: Icmpv6Builder) -> Self
Converts to this type from the input type.
Source§impl From<Ipv4Builder> for LayerStack
impl From<Ipv4Builder> for LayerStack
Source§fn from(builder: Ipv4Builder) -> Self
fn from(builder: Ipv4Builder) -> Self
Converts to this type from the input type.
Source§impl From<Ipv6Builder> for LayerStack
impl From<Ipv6Builder> for LayerStack
Source§fn from(builder: Ipv6Builder) -> Self
fn from(builder: Ipv6Builder) -> Self
Converts to this type from the input type.
Source§impl From<TcpBuilder> for LayerStack
impl From<TcpBuilder> for LayerStack
Source§fn from(builder: TcpBuilder) -> Self
fn from(builder: TcpBuilder) -> Self
Converts to this type from the input type.
Source§impl From<UdpBuilder> for LayerStack
impl From<UdpBuilder> for LayerStack
Source§fn from(builder: UdpBuilder) -> Self
fn from(builder: UdpBuilder) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for LayerStack
impl RefUnwindSafe for LayerStack
impl Send for LayerStack
impl Sync for LayerStack
impl Unpin for LayerStack
impl UnsafeUnpin for LayerStack
impl UnwindSafe for LayerStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more