Skip to main content

Container

Enum Container 

Source
#[non_exhaustive]
pub enum Container { Word { bits: u64, prefix: u64, prefix_value: Option<u128>, endian: Endian, order: BitOrder, }, Bytes { bytes: usize, endian: Endian, }, Words { words: usize, endian: Endian, order: BitOrder, }, }
Expand description

How a layout addresses its fields.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Word

Word mode: bit fields in one container of whole bytes.

The container can be any size, but a field is at most 64 bits.

Fields

§bits: u64

The size in bits, a positive multiple of 8.

§prefix: u64

Leading bits the enclosing dispatch reads, which this layout’s fields do not cover.

Encode writes zeros there unless prefix_value is set.

§prefix_value: Option<u128>

The prefix’s value. Encode writes it and decode refuses any other.

§endian: Endian

The byte order.

§order: BitOrder

The bit order.

§

Bytes

Byte mode: byte-aligned scalars.

Fields

§bytes: usize

The size in bytes.

§endian: Endian

The byte order.

§

Words

Words mode: bit fields in a sequence of 16-bit words.

Fields

§words: usize

The number of words.

§endian: Endian

Each word’s byte order.

§order: BitOrder

The bit order within each word.

Implementations§

Source§

impl Container

Source

pub fn word(bits: u64, endian: Endian, order: BitOrder) -> Self

A Container::Word with no prefix.

Source

pub fn admits(&self, name: &str, kind: &Kind) -> Result<(), Invalid>

Checks that this container allows a field of kind.

§Errors

Invalid::Field naming the field.

Source

pub fn unit(&self) -> Unit

The unit of the size in #[layout(..)].

Source

pub fn units(&self) -> u64

The size in units: the N of #[layout(<unit> = N)].

Source

pub fn endian(&self) -> Endian

The byte order.

Source

pub fn order(&self) -> Option<BitOrder>

The bit order, or None in byte mode.

Source

pub fn is_bit_addressed(&self) -> bool

Whether fields are addressed in bits.

Source

pub fn bits(&self) -> u64

The size in bits.

Source

pub fn prefix(&self) -> u64

Leading bits the enclosing dispatch reads.

Source

pub fn field_bits(&self) -> u64

The bits the fields must cover: bits minus prefix.

Source

pub fn interior_boundary(&self) -> Option<u64>

The word size in words mode (Some(16)), and None otherwise.

Source

pub fn physical(&self, kind: &Kind, start: u64) -> u64

The wire position of a field declared at bit start, after applying BitOrder.

Under order = msb, scalar and codec fields are mirrored within their word. FIELDS and STATED use this position. check_stated uses declared positions.

Source

pub fn check_stated( &self, field: &str, kind: &Kind, stated: Stated, declared: u64, ) -> Result<(), String>

Checks an #[at] position against the field’s declared position.

Under msb, #[at] counts in declared order, as a big-endian spec’s table does.

§Errors

The diagnostic text. Under msb it gives both positions.

Trait Implementations§

Source§

impl Clone for Container

Source§

fn clone(&self) -> Container

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Container

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Container

Source§

impl Hash for Container

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Container

Source§

fn eq(&self, other: &Container) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Container

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.