tock_registers::debug

Trait FieldValueEnumSeq

Source
pub trait FieldValueEnumSeq<U: UIntLike> {
    // Required method
    fn recurse_try_from_value(
        data: &mut impl FnMut() -> U,
        f: &mut impl FnMut(&dyn Debug),
    );
}
Expand description

FieldValueEnumSeq is a debug helper trait representing a sequence of field enum types.

It provides methods to recurse through this sequence of types and thus call methods on them, such as try_from_value.

Its primary use lies in the RegisterDebugInfo trait. This trait provides facilities useful for providing information on the layout of a register (such as, which fields it has and which known values those fields can assume). Such information is usually only available at compile time. This trait makes runtime-representable data available at runtime. However, information encoded solely in types can’t simply be used at runtime, which is where this trait comes in.

Required Methods§

Source

fn recurse_try_from_value( data: &mut impl FnMut() -> U, f: &mut impl FnMut(&dyn Debug), )

Iterates over the sequence of types and performs the following steps:

  1. Invokes the data function argument. This is expected to provide the numeric (UIntLike) value of the register field that the current type corresponds to.

  2. Invoke try_from_value on the current field enum type, passing the value returned by data.

  3. Provide the returned value to the f function argument. This is either the enum representation (if the field value belongs to a known variant, or the numeric field value returned by data.

In practice, this method should be used to iterate over types and other runtime-accessible information in tandem, to produce a human-readable register dump.

Importantly, data is invoked for every type in the sequence, and every invocation of data is followed by a single invocation of f.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§