Trait binary_layout::FieldSliceAccess [−][src]
pub trait FieldSliceAccess<'a>: Field { type SliceType: 'a; type MutSliceType: 'a; fn data(storage: &'a [u8]) -> Self::SliceType; fn data_mut(storage: &'a mut [u8]) -> Self::MutSliceType; }
Expand description
This trait is implemented for fields with “slice access”, i.e. fields that are read/write directly without a copy by returning a borrowed slice to the underlying data.
Associated Types
type MutSliceType: 'a
type MutSliceType: 'a
The type of slice returned from calls requesting write access
Required methods
Borrow the data in the byte array with write access using the Field API.
Example:
use binary_layout::prelude::*; define_layout!(my_layout, LittleEndian, { //... other fields ... tail_data: [u8], }); fn func(storage_data: &mut [u8]) { let tail_data: &mut [u8] = my_layout::tail_data::data_mut(storage_data); }
Implementors
impl<'a, E: Endianness, const N: usize, const OFFSET_: usize> FieldSliceAccess<'a> for PrimitiveField<[u8; N], E, OFFSET_>
impl<'a, E: Endianness, const OFFSET_: usize> FieldSliceAccess<'a> for PrimitiveField<[u8], E, OFFSET_>