Struct packet

Source
pub struct packet(/* private fields */);
Expand description

A byte sequence representing an ARP packet.

Implementations§

Source§

impl arp

Source

pub fn new_unchecked(buffer: &[u8]) -> &arp

Imbue a raw octet buffer with ARP packet structure.

Source

pub fn new_unchecked_mut(buffer: &mut [u8]) -> &mut arp

Imbue a mutable octet buffer with ARP packet structure.

Source

pub fn new_checked(data: &[u8]) -> Result<&arp>

Shorthand for a combination of new_unchecked and check_len.

Source

pub fn as_bytes(&self) -> &[u8]

Unwrap the packet as a raw byte slice.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Unwrap the packet as a mutable raw byte slice.

Source

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.

Source

pub fn hardware_type(&self) -> Hardware

Return the hardware type field.

Source

pub fn protocol_type(&self) -> Protocol

Return the protocol type field.

Source

pub fn hardware_len(&self) -> u8

Return the hardware length field.

Source

pub fn protocol_len(&self) -> u8

Return the protocol length field.

Source

pub fn operation(&self) -> Operation

Return the operation field.

Source

pub fn source_hardware_addr(&self) -> Address

Return the source hardware address field.

Source

pub fn source_protocol_addr(&self) -> IpAddress

Return the source protocol address field.

Source

pub fn target_hardware_addr(&self) -> Address

Return the target hardware address field.

Source

pub fn target_protocol_addr(&self) -> IpAddress

Return the target protocol address field.

Source

pub fn set_hardware_type(&mut self, value: Hardware)

Set the hardware type field.

Source

pub fn set_protocol_type(&mut self, value: Protocol)

Set the protocol type field.

Source

pub fn set_hardware_len(&mut self, value: u8)

Set the hardware length field.

Source

pub fn set_protocol_len(&mut self, value: u8)

Set the protocol length field.

Source

pub fn set_operation(&mut self, value: Operation)

Set the operation field.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl AsMut<[u8]> for arp

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for arp

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for arp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for arp

Source§

fn eq(&self, other: &arp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PrettyPrint for arp

Source§

fn pretty_print( buffer: &[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
Source§

impl Eq for arp

Source§

impl StructuralPartialEq for arp

Auto Trait Implementations§

§

impl Freeze for arp

§

impl RefUnwindSafe for arp

§

impl Send for arp

§

impl !Sized for arp

§

impl Sync for arp

§

impl Unpin for arp

§

impl UnwindSafe for arp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more