pub struct IPv4EndpointOption<T: AsRef<[u8]>> { /* private fields */ }Expand description
Zero-copy wrapper around IPv4 Endpoint Option (12 bytes total: 4 header + 8 data).
IPv4 endpoint options convey IPv4 address, port, and transport protocol for service endpoints.
Wire format (12 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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| IPv4 Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved | Protocol | Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Implementations§
Source§impl<T: AsRef<[u8]>> IPv4EndpointOption<T>
impl<T: AsRef<[u8]>> IPv4EndpointOption<T>
Sourcepub const LENGTH: usize = 12usize
pub const LENGTH: usize = 12usize
IPv4 endpoint option wire format size in bytes (4 header + 8 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 12 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 ipv4_address(&self) -> [u8; 4]
pub fn ipv4_address(&self) -> [u8; 4]
Get the IPv4 address (4 bytes at offset 4-7).
§Returns
The IPv4 address as a 4-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]>> IPv4EndpointOption<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> IPv4EndpointOption<T>
Sourcepub fn set_ipv4_address(&mut self, addr: [u8; 4])
pub fn set_ipv4_address(&mut self, addr: [u8; 4])
Set the IPv4 address (4 bytes at offset 4-7).
§Parameters
addr- The IPv4 address as a 4-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 9).
§Parameters
proto- Protocol value (0x06=TCP, 0x11=UDP)
Trait Implementations§
Source§impl<T: Clone + AsRef<[u8]>> Clone for IPv4EndpointOption<T>
impl<T: Clone + AsRef<[u8]>> Clone for IPv4EndpointOption<T>
Source§fn clone(&self) -> IPv4EndpointOption<T>
fn clone(&self) -> IPv4EndpointOption<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 IPv4EndpointOption<T>
Auto Trait Implementations§
impl<T> Freeze for IPv4EndpointOption<T>where
T: Freeze,
impl<T> RefUnwindSafe for IPv4EndpointOption<T>where
T: RefUnwindSafe,
impl<T> Send for IPv4EndpointOption<T>where
T: Send,
impl<T> Sync for IPv4EndpointOption<T>where
T: Sync,
impl<T> Unpin for IPv4EndpointOption<T>where
T: Unpin,
impl<T> UnwindSafe for IPv4EndpointOption<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