pub struct ArpPacket<T: AsRef<[u8]>> { /* private fields */ }Expand description
A read/write wrapper around an Address Resolution Protocol packet buffer.
Implementations
sourceimpl<T: AsRef<[u8]>> Packet<T>
impl<T: AsRef<[u8]>> Packet<T>
sourcepub fn new_unchecked(buffer: T) -> Packet<T>
pub fn new_unchecked(buffer: T) -> Packet<T>
Imbue a raw octet buffer with ARP packet structure.
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 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_hardware_len or set_protocol_len.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
sourcepub fn hardware_type(&self) -> Hardware
pub fn hardware_type(&self) -> Hardware
Return the hardware type field.
sourcepub fn protocol_type(&self) -> Protocol
pub fn protocol_type(&self) -> Protocol
Return the protocol type field.
sourcepub fn hardware_len(&self) -> u8
pub fn hardware_len(&self) -> u8
Return the hardware length field.
sourcepub fn protocol_len(&self) -> u8
pub fn protocol_len(&self) -> u8
Return the protocol length field.
sourcepub fn source_hardware_addr(&self) -> &[u8]
pub fn source_hardware_addr(&self) -> &[u8]
Return the source hardware address field.
sourcepub fn source_protocol_addr(&self) -> &[u8]
pub fn source_protocol_addr(&self) -> &[u8]
Return the source protocol address field.
sourcepub fn target_hardware_addr(&self) -> &[u8]
pub fn target_hardware_addr(&self) -> &[u8]
Return the target hardware address field.
sourcepub fn target_protocol_addr(&self) -> &[u8]
pub fn target_protocol_addr(&self) -> &[u8]
Return the target protocol address field.
sourceimpl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
sourcepub fn set_hardware_type(&mut self, value: Hardware)
pub fn set_hardware_type(&mut self, value: Hardware)
Set the hardware type field.
sourcepub fn set_protocol_type(&mut self, value: Protocol)
pub fn set_protocol_type(&mut self, value: Protocol)
Set the protocol type field.
sourcepub fn set_hardware_len(&mut self, value: u8)
pub fn set_hardware_len(&mut self, value: u8)
Set the hardware length field.
sourcepub fn set_protocol_len(&mut self, value: u8)
pub fn set_protocol_len(&mut self, value: u8)
Set the protocol length field.
sourcepub fn set_operation(&mut self, value: Operation)
pub fn set_operation(&mut self, value: Operation)
Set the operation field.
sourcepub fn set_source_hardware_addr(&mut self, value: &[u8])
pub fn set_source_hardware_addr(&mut self, value: &[u8])
Set the source hardware address field.
Panics
The function panics if value is not self.hardware_len() long.
sourcepub fn set_source_protocol_addr(&mut self, value: &[u8])
pub fn set_source_protocol_addr(&mut self, value: &[u8])
Set the source protocol address field.
Panics
The function panics if value is not self.protocol_len() long.
sourcepub fn set_target_hardware_addr(&mut self, value: &[u8])
pub fn set_target_hardware_addr(&mut self, value: &[u8])
Set the target hardware address field.
Panics
The function panics if value is not self.hardware_len() long.
sourcepub fn set_target_protocol_addr(&mut self, value: &[u8])
pub fn set_target_protocol_addr(&mut self, value: &[u8])
Set the target protocol address field.
Panics
The function panics if value is not self.protocol_len() long.
Trait Implementations
sourceimpl<T: AsRef<[u8]>> PrettyPrint for Packet<T>
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T>
sourcefn pretty_print(
buffer: &dyn AsRef<[u8]>,
f: &mut Formatter<'_>,
indent: &mut PrettyIndent
) -> Result
fn pretty_print(
buffer: &dyn AsRef<[u8]>,
f: &mut Formatter<'_>,
indent: &mut PrettyIndent
) -> Result
Write a concise, formatted representation of a packet contained in the provided buffer, and any nested packets it may contain. Read more
impl<T: AsRef<[u8]>> StructuralPartialEq for Packet<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Packet<T> where
T: RefUnwindSafe,
impl<T> Send for Packet<T> where
T: Send,
impl<T> Sync for Packet<T> where
T: Sync,
impl<T> Unpin for Packet<T> where
T: Unpin,
impl<T> UnwindSafe for Packet<T> where
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more