pub struct Ipv6Builder { /* private fields */ }Expand description
Builder for IPv6 packet headers.
Implementations§
Source§impl Ipv6Builder
impl Ipv6Builder
Sourcepub fn traffic_class(self, tc: u8) -> Self
pub fn traffic_class(self, tc: u8) -> Self
Set the Traffic Class field.
Sourcepub fn flow_label(self, fl: u32) -> Self
pub fn flow_label(self, fl: u32) -> Self
Set the Flow Label (20 bits; upper 12 bits are ignored).
Sourcepub fn next_header(self, nh: u8) -> Self
pub fn next_header(self, nh: u8) -> Self
Set the Next Header field.
Sourcepub fn payload<T: Into<Vec<u8>>>(self, data: T) -> Self
pub fn payload<T: Into<Vec<u8>>>(self, data: T) -> Self
Set the payload bytes (appended after the 40-byte header).
Sourcepub fn auto_length(self, auto: bool) -> Self
pub fn auto_length(self, auto: bool) -> Self
Configure automatic payload length calculation (default: true).
Sourcepub fn payload_len(self, len: u16) -> Self
pub fn payload_len(self, len: u16) -> Self
Manually override the payload length field.
Only used when auto_length is false.
Sourcepub fn header_size(&self) -> usize
pub fn header_size(&self) -> usize
Get the header size (always 40 bytes for IPv6).
Sourcepub fn packet_size(&self) -> usize
pub fn packet_size(&self) -> usize
Get the total packet size (header + payload).
Sourcepub fn build(&self) -> Vec<u8> ⓘ
pub fn build(&self) -> Vec<u8> ⓘ
Build the IPv6 header + payload into a byte vector.
§Byte layout:
- Byte 0: version (6) in high 4 bits | TC high nibble in low 4 bits
- Byte 1: TC low nibble in high 4 bits | FL bits 19-16 in low 4 bits
- Bytes 2-3: FL bits 15-0 (big-endian)
- Bytes 4-5:
payload_len(big-endian) - Byte 6:
next_header - Byte 7:
hop_limit - Bytes 8-23: source address (16 bytes)
- Bytes 24-39: destination address (16 bytes)
- Bytes 40+: payload
Trait Implementations§
Source§impl Clone for Ipv6Builder
impl Clone for Ipv6Builder
Source§fn clone(&self) -> Ipv6Builder
fn clone(&self) -> Ipv6Builder
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 Ipv6Builder
impl Debug for Ipv6Builder
Source§impl Default for Ipv6Builder
impl Default for Ipv6Builder
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 IntoLayerStackEntry for Ipv6Builder
impl IntoLayerStackEntry for Ipv6Builder
fn into_layer_stack_entry(self) -> LayerStackEntry
Auto Trait Implementations§
impl Freeze for Ipv6Builder
impl RefUnwindSafe for Ipv6Builder
impl Send for Ipv6Builder
impl Sync for Ipv6Builder
impl Unpin for Ipv6Builder
impl UnsafeUnpin for Ipv6Builder
impl UnwindSafe for Ipv6Builder
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