pub struct IPv4Reader<'a> {
pub bytes: &'a [u8],
}
Expand description
Reads IPv4 header fields.
Fields§
§bytes: &'a [u8]
Implementations§
Source§impl<'a> IPv4Reader<'a>
impl<'a> IPv4Reader<'a>
Sourcepub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
pub fn new(bytes: &'a [u8]) -> Result<Self, &'static str>
Creates a new IPv4Reader
from the given slice.
Sourcepub fn total_length(&self) -> u16
pub fn total_length(&self) -> u16
Returns the total length field.
Includes the entire packet (header and payload).
Sourcepub fn fragment_offset(&self) -> u16
pub fn fragment_offset(&self) -> u16
Returns the fragment offset field.
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Returns the indicated header length in bytes.
Sourcepub fn header(&self) -> Result<&'a [u8], &'static str>
pub fn header(&self) -> Result<&'a [u8], &'static str>
Returns a reference to the header.
May fail if the indicated header length exceeds the allocated buffer.
Sourcepub fn payload(&self) -> Result<&'a [u8], &'static str>
pub fn payload(&self) -> Result<&'a [u8], &'static str>
Returns a reference to the payload.
May fail if the indicated header length exceeds the allocated buffer.
Sourcepub fn valid_checksum(&self) -> Result<bool, &'static str>
pub fn valid_checksum(&self) -> Result<bool, &'static str>
Verifies the checksum field.
Trait Implementations§
Source§impl Debug for IPv4Reader<'_>
impl Debug for IPv4Reader<'_>
Source§impl<'a> ParseReader<'a> for IPv4Reader<'a>
impl<'a> ParseReader<'a> for IPv4Reader<'a>
Source§impl<'a> PartialEq for IPv4Reader<'a>
impl<'a> PartialEq for IPv4Reader<'a>
Source§impl<'a> VerifyReader<'a> for IPv4Reader<'a>
impl<'a> VerifyReader<'a> for IPv4Reader<'a>
impl<'a> StructuralPartialEq for IPv4Reader<'a>
Auto Trait Implementations§
impl<'a> Freeze for IPv4Reader<'a>
impl<'a> RefUnwindSafe for IPv4Reader<'a>
impl<'a> Send for IPv4Reader<'a>
impl<'a> Sync for IPv4Reader<'a>
impl<'a> Unpin for IPv4Reader<'a>
impl<'a> UnwindSafe for IPv4Reader<'a>
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