Trait binary_layout::prelude::FieldMetadata[][src]

pub trait FieldMetadata {
    type Type: ?Sized;

    const OFFSET: usize;
}

This trait offers access to the metadata of a field in a layout

Associated Types

type Type: ?Sized[src][]

The data type of the field, e.g. u8, i32, …

Associated Constants

const OFFSET: usize[src][]

The offset of the field in the layout.

Example

use binary_layout::prelude::*;

define_layout!(my_layout, LittleEndian, {
  field1: u16,
  field2: i32,
  field3: u8,
});

fn main() {
    assert_eq!(0, my_layout::field1::OFFSET);
    assert_eq!(2, my_layout::field2::OFFSET);
    assert_eq!(6, my_layout::field3::OFFSET);
}

Implementors

impl<T: ?Sized, E: Endianness, const OFFSET_: usize> FieldMetadata for Field<T, E, OFFSET_>[src]