pub struct IPv6EndpointOption<T: AsRef<[u8]>> { /* private fields */ }Expand description
Zero-copy wrapper around IPv6 Endpoint Option (24 bytes total: 4 header + 20 data).
IPv6 endpoint options convey IPv6 address, port, and transport protocol for service endpoints.
Wire format (24 bytes):
0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Type |D| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| IPv6 Address (16 bytes) |
| |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved | Protocol | Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Implementations§
Source§impl<T: AsRef<[u8]>> IPv6EndpointOption<T>
impl<T: AsRef<[u8]>> IPv6EndpointOption<T>
Sourcepub const LENGTH: usize = 24usize
pub const LENGTH: usize = 24usize
IPv6 endpoint option wire format size in bytes (4 header + 20 data).
Sourcepub fn new_unchecked(buffer: T) -> Self
pub fn new_unchecked(buffer: T) -> Self
Sourcepub fn new_checked(buffer: T) -> Result<Self>
pub fn new_checked(buffer: T) -> Result<Self>
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Validate that the buffer is at least 24 bytes long.
§Returns
Ok(())if buffer meets minimum length requirementErr(Error)if buffer is too short
Sourcepub fn header(&self) -> OptionHeader<&[u8]>
pub fn header(&self) -> OptionHeader<&[u8]>
Get a view of the option header (first 4 bytes).
§Returns
OptionHeader wrapper around the header bytes
Sourcepub fn ipv6_address(&self) -> [u8; 16]
pub fn ipv6_address(&self) -> [u8; 16]
Get the IPv6 address (16 bytes at offset 4-19).
§Returns
The IPv6 address as a 16-byte array in network byte order
Sourcepub fn transport_protocol(&self) -> u8
pub fn transport_protocol(&self) -> u8
Sourcepub fn check_protocol(&self) -> Result<()>
pub fn check_protocol(&self) -> Result<()>
Validate the transport protocol field.
§Returns
Ok(())if protocol is TCP (0x06) or UDP (0x11)Err(Error::InvalidProtocol)if protocol is unknown
Source§impl<T: AsRef<[u8]> + AsMut<[u8]>> IPv6EndpointOption<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> IPv6EndpointOption<T>
Sourcepub fn set_ipv6_address(&mut self, addr: [u8; 16])
pub fn set_ipv6_address(&mut self, addr: [u8; 16])
Set the IPv6 address (16 bytes at offset 4-19).
§Parameters
addr- The IPv6 address as a 16-byte array in network byte order
Sourcepub fn set_transport_protocol(&mut self, proto: u8)
pub fn set_transport_protocol(&mut self, proto: u8)
Set the transport protocol (1 byte at offset 21).
§Parameters
proto- Protocol value (0x06=TCP, 0x11=UDP)
Trait Implementations§
Source§impl<T: Clone + AsRef<[u8]>> Clone for IPv6EndpointOption<T>
impl<T: Clone + AsRef<[u8]>> Clone for IPv6EndpointOption<T>
Source§fn clone(&self) -> IPv6EndpointOption<T>
fn clone(&self) -> IPv6EndpointOption<T>
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 moreimpl<T: Copy + AsRef<[u8]>> Copy for IPv6EndpointOption<T>
Auto Trait Implementations§
impl<T> Freeze for IPv6EndpointOption<T>where
T: Freeze,
impl<T> RefUnwindSafe for IPv6EndpointOption<T>where
T: RefUnwindSafe,
impl<T> Send for IPv6EndpointOption<T>where
T: Send,
impl<T> Sync for IPv6EndpointOption<T>where
T: Sync,
impl<T> Unpin for IPv6EndpointOption<T>where
T: Unpin,
impl<T> UnwindSafe for IPv6EndpointOption<T>where
T: UnwindSafe,
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