pub trait FieldCopyAccess: Field {
    type HighLevelType;

    fn read(storage: &[u8]) -> Self::HighLevelType;
    fn write(storage: &mut [u8], v: Self::HighLevelType);
}
Expand description

This trait is implemented for fields with “copy access”, i.e. fields that read/write data by copying it from/to the binary blob. Examples of this are primitive types like u8, i32, …

Required Associated Types

The data type that is returned from read calls and has to be passed in to write calls. This can be different from the primitive type used in the binary blob, since that primitive type can be wrapped (see WrappedField ) into a high level type before being returned from read calls (or vice versa unwrapped when writing).

Required Methods

Read the field from a given data region, assuming the defined layout, using the Field API.

Example:
use binary_layout::prelude::*;

define_layout!(my_layout, LittleEndian, {
  //... other fields ...
  some_integer_field: u16,
  //... other fields ...
});

fn func(storage_data: &[u8]) {
  let read: u16 = my_layout::some_integer_field::read(storage_data);
}

Write the field to a given data region, assuming the defined layout, using the Field API.

Example:
use binary_layout::prelude::*;

define_layout!(my_layout, LittleEndian, {
  //... other fields ...
  some_integer_field: u16,
  //... other fields ...
});

fn func(storage_data: &mut [u8]) {
  my_layout::some_integer_field::write(storage_data, 10);
}

Implementors