Struct binary_layout::example::icmp_packet::View[][src]

pub struct View<S> { /* fields omitted */ }

The View struct defines the FieldView API. An instance of View wraps a storage (either borrowed or owned) and allows accessors for the layout fields.

Implementations

impl<S> View<S>[src]

pub fn new(storage: S) -> Self[src]

You can create views over a storage by calling View::new.

S is the type of underlying storage. It can be

  • Immutable borrowed storage: &[u8]
  • Mutable borrowed storage: &mut [u8]
  • Owning storage: impl AsRef<u8> (for example: Vec<u8>)

pub fn into_storage(self) -> S[src]

This destroys the view and returns the underlying storage back to you. This is useful if you created an owning view (e.g. vased on Vec<u8>) and now need the underlying Vec<u8> back.

pub fn into_packet_type(self) -> FieldView<S, packet_type>[src]

Destroy the View and return a field accessor to the packet_type field owning the storage. This is mostly useful for FieldView::extract

pub fn into_code(self) -> FieldView<S, code>[src]

Destroy the View and return a field accessor to the code field owning the storage. This is mostly useful for FieldView::extract

pub fn into_checksum(self) -> FieldView<S, checksum>[src]

Destroy the View and return a field accessor to the checksum field owning the storage. This is mostly useful for FieldView::extract

pub fn into_rest_of_header(self) -> FieldView<S, rest_of_header>[src]

Destroy the View and return a field accessor to the rest_of_header field owning the storage. This is mostly useful for FieldView::extract

pub fn into_data_section(self) -> FieldView<S, data_section>[src]

Destroy the View and return a field accessor to the data_section field owning the storage. This is mostly useful for FieldView::extract

impl<S: AsRef<[u8]>> View<S>[src]

pub fn packet_type(&self) -> FieldView<&[u8], packet_type>[src]

Return a FieldView with read access to the packet_type field

pub fn code(&self) -> FieldView<&[u8], code>[src]

Return a FieldView with read access to the code field

pub fn checksum(&self) -> FieldView<&[u8], checksum>[src]

Return a FieldView with read access to the checksum field

pub fn rest_of_header(&self) -> FieldView<&[u8], rest_of_header>[src]

Return a FieldView with read access to the rest_of_header field

pub fn data_section(&self) -> FieldView<&[u8], data_section>[src]

Return a FieldView with read access to the data_section field

impl<S: AsMut<[u8]>> View<S>[src]

pub fn packet_type_mut(&mut self) -> FieldView<&mut [u8], packet_type>[src]

Return a FieldView with write access to the packet_type field

pub fn code_mut(&mut self) -> FieldView<&mut [u8], code>[src]

Return a FieldView with write access to the code field

pub fn checksum_mut(&mut self) -> FieldView<&mut [u8], checksum>[src]

Return a FieldView with write access to the checksum field

pub fn rest_of_header_mut(&mut self) -> FieldView<&mut [u8], rest_of_header>[src]

Return a FieldView with write access to the rest_of_header field

pub fn data_section_mut(&mut self) -> FieldView<&mut [u8], data_section>[src]

Return a FieldView with write access to the data_section field

Auto Trait Implementations

impl<S> RefUnwindSafe for View<S> where
    S: RefUnwindSafe

impl<S> Send for View<S> where
    S: Send

impl<S> Sync for View<S> where
    S: Sync

impl<S> Unpin for View<S> where
    S: Unpin

impl<S> UnwindSafe for View<S> where
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.