Struct etherparse::UdpSlice
source · pub struct UdpSlice<'a> { /* private fields */ }
Expand description
Slice containing the UDP headers & payload.
Implementations§
source§impl<'a> UdpSlice<'a>
impl<'a> UdpSlice<'a>
sourcepub fn from_slice(slice: &'a [u8]) -> Result<UdpSlice<'a>, LenError>
pub fn from_slice(slice: &'a [u8]) -> Result<UdpSlice<'a>, LenError>
Decode length from UDP header and restrict slice to the length of the header including the payload.
Note that this method fall backs to the length of the slice in the case the length field in the UDP header is set to zero.
sourcepub fn from_slice_lax(slice: &'a [u8]) -> Result<UdpSlice<'a>, LenError>
pub fn from_slice_lax(slice: &'a [u8]) -> Result<UdpSlice<'a>, LenError>
Try decoding length from UDP header and restrict slice to the length of the header including the payload if possible. If not the slice length is used as a fallback value.
Note that this method fall also backs to the length of the slice in the case the length field in the UDP header is set to zero or smaller then the minimum header length.
sourcepub fn header_slice(&self) -> &'a [u8] ⓘ
pub fn header_slice(&self) -> &'a [u8] ⓘ
Return the slice containing the UDP header.
sourcepub fn payload_len_source(&self) -> LenSource
pub fn payload_len_source(&self) -> LenSource
Value that was used to determine the length of the payload.
sourcepub fn source_port(&self) -> u16
pub fn source_port(&self) -> u16
Reads the “udp source port” in the UDP header.
sourcepub fn destination_port(&self) -> u16
pub fn destination_port(&self) -> u16
Reads the “udp destination port” in the UDP header.
sourcepub const fn header_len(&self) -> usize
pub const fn header_len(&self) -> usize
Length of the UDP header (equal to crate::UdpHeader::LEN
).
sourcepub const fn header_len_u16(&self) -> u16
pub const fn header_len_u16(&self) -> u16
Length of the UDP header in an u16
(equal to crate::UdpHeader::LEN_U16
).