Struct binary_layout::example::icmp_packet::View [−][src]
pub struct View<S> { /* fields omitted */ }Expand description
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.
This view is based on the following layout definition:
define_layout!(icmp_packet, BigEndian, {
packet_type: u8,
code: u8,
checksum: u16,
rest_of_header: [u8; 4],
data_section: [u8],
});Implementations
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>)
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.
Destroy the View and return a field accessor to the packet_type field owning the storage. This is mostly useful for FieldView::extract
Destroy the View and return a field accessor to the code field owning the storage. This is mostly useful for FieldView::extract
Destroy the View and return a field accessor to the checksum field owning the storage. This is mostly useful for FieldView::extract
Destroy the View and return a field accessor to the rest_of_header field owning the storage. This is mostly useful for FieldView::extract
Destroy the View and return a field accessor to the data_section field owning the storage. This is mostly useful for FieldView::extract
Return a FieldView with write access to the packet_type field
Return a FieldView with write access to the code field
Return a FieldView with write access to the checksum field
Return a FieldView with write access to the rest_of_header field
Return a FieldView with write access to the data_section field