pub struct Packet<T: Payload> { /* private fields */ }Expand description
A read/write wrapper around an Internet Protocol version 6 packet buffer.
Implementations§
Source§impl<T: Payload> Packet<T>
impl<T: Payload> Packet<T>
Sourcepub fn new_checked(buffer: T) -> Result<Packet<T>>
pub fn new_checked(buffer: T) -> Result<Packet<T>>
Shorthand for a combination of new_unchecked and check_len.
Sourcepub fn get_ref(&self) -> &T
pub fn get_ref(&self) -> &T
Get an immutable reference to the whole buffer.
Useful if the buffer is some other packet encapsulation.
Sourcepub fn new_unchecked(buffer: T, repr: Repr) -> Self
pub fn new_unchecked(buffer: T, repr: Repr) -> Self
Create a new packet without checking the representation.
Misuse may lead to panics from out-of-bounds access or other subtle inconsistencies. Since the representation might not represent the actual content in the payload, this also might mean that seemingly inconsistent values are returned. The usage is still memory safe though.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
Methods from Deref<Target = ipv6>§
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Ensure that no accessor method will panic if called.
Returns Err(Error::Truncated) if the buffer is too short.
The result of this check is invalidated by calling set_payload_len.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Return the header length.
Sourcepub fn traffic_class(&self) -> u8
pub fn traffic_class(&self) -> u8
Return the traffic class.
Sourcepub fn flow_label(&self) -> u32
pub fn flow_label(&self) -> u32
Return the flow label field.
Sourcepub fn payload_len(&self) -> u16
pub fn payload_len(&self) -> u16
Return the payload length field.
Sourcepub fn next_header(&self) -> Protocol
pub fn next_header(&self) -> Protocol
Return the next header field.
Sourcepub fn payload_slice(&self) -> &[u8]
pub fn payload_slice(&self) -> &[u8]
Return a pointer to the payload.