Struct MessageSlicer

Source
pub struct MessageSlicer<'de> { /* private fields */ }
Expand description

MessageSlicer wraps a Slicer to provide:

  1. Methods to parse fields because we already know the fixed length of those fields.
  2. A validated input. We know a Message must be a minimum length because we know the size of certain fields. This allows us to use faster unchecked parsing if we check the length at instantiation.

MessageSlicer is useful to implement from_bytes from DecodeMessage.

Implementations§

Source§

impl<'de> MessageSlicer<'de>

Source

pub fn new(input: &'de [u8]) -> Result<Self>

Creates a MessageSlicer for use in DecodeMessage

Source

pub fn parse_op(&self) -> &'de [u8]

Parses 1 byte to be used for the op field

Source

pub fn parse_htype(&self) -> &'de [u8]

Parses 1 byte to be used for the htype field

Source

pub fn parse_hlen(&self) -> &'de [u8]

Parses 1 byte to be used for the hlen field

Source

pub fn parse_hops(&self) -> &'de [u8]

Parses 1 byte to be used for the hops field

Source

pub fn parse_xid(&self) -> &'de [u8]

Parses 4 bytes to be used for the xid field

Source

pub fn parse_secs(&self) -> &'de [u8]

Parses 2 bytes to be used for the secs field

Source

pub fn parse_flags(&self) -> &'de [u8]

Parses 2 bytes to be used for the flags field

Source

pub fn parse_ciaddr(&self) -> &'de [u8]

Parses 4 bytes to be used for the ciaddr field

Source

pub fn parse_yiaddr(&self) -> &'de [u8]

Parses 4 bytes to be used for the yiaddr field

Source

pub fn parse_siaddr(&self) -> &'de [u8]

Parses 4 bytes to be used for the siaddr field

Source

pub fn parse_giaddr(&self) -> &'de [u8]

Parses 4 bytes to be used for the giaddr field

Source

pub fn parse_chaddr(&self) -> &'de [u8]

Parses 16 bytes to be used for the chaddr field

Source

pub fn parse_sname(&self) -> &'de [u8]

Parses 64 bytes to be used for the sname field

Source

pub fn parse_file(&self) -> &'de [u8]

Parses 128 bytes to be used for the file field

Source

pub fn parse_magic(&self) -> &'de [u8]

Parses 4 bytes to be used as the magic field

Source

pub fn parse_options(&self) -> &'de [u8]

Parses all remaining bytes in the input to be used as the options field

Auto Trait Implementations§

§

impl<'de> !Freeze for MessageSlicer<'de>

§

impl<'de> !RefUnwindSafe for MessageSlicer<'de>

§

impl<'de> Send for MessageSlicer<'de>

§

impl<'de> !Sync for MessageSlicer<'de>

§

impl<'de> Unpin for MessageSlicer<'de>

§

impl<'de> UnwindSafe for MessageSlicer<'de>

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V