Skip to main content

ExpectedTraceBuilder

Struct ExpectedTraceBuilder 

Source
pub struct ExpectedTraceBuilder<'a> { /* private fields */ }
Expand description

Builder for recording expected MMIO access sequences within a closure.

Adopts a receiver-based closure architecture (mock.expect(|t| { ... })) where expectations are posted to the [Scoreboard] via standard Rust method calls.

The syntax is intended to work seamlessly with standard Rust tooling (rustfmt, rust-analyzer, go-to-definition, and autocomplete). The raw offset methods are spelled out one per access width, rather than generated by a macro, so that autocomplete lists them.

Each expectation method automatically captures the caller source location (Location::caller). This information is included in the diagnostic information produced by test failures.

Implementations§

Source§

impl<'a> ExpectedTraceBuilder<'a>

Source

pub fn read<R: ReadableRegister>(&mut self, value: R::Value)

Posts an expectation for a read from register R, returning value.

The register byte offset (R::OFFSET) and access width (AccessSize::of::<R::Value>()) are automatically deduced from the ReadableRegister definition.

Source

pub fn write<R: WritableRegister>(&mut self, value: R::Value)

Posts an expectation for a write of value to register R.

The register byte offset (R::OFFSET) and access width (AccessSize::of::<R::Value>()) are automatically deduced from the WritableRegister definition.

Source

pub fn read_indexed<R: ReadableIndexedRegister>( &mut self, index: usize, value: R::Value, )

Posts an expectation for reading value from register R at index.

The byte offset is R::BASE_OFFSET + index * R::STRIDE.

§Panics

Panics if index is greater than or equal to R::COUNT.

Source

pub fn write_indexed<R: WritableIndexedRegister>( &mut self, index: usize, value: R::Value, )

Posts an expectation for a write of value to register R at index.

The byte offset is R::BASE_OFFSET + index * R::STRIDE.

§Panics

Panics if index is greater than or equal to R::COUNT.

Source

pub fn poll<R: ReadableRegister>( &mut self, values: impl IntoIterator<Item = R::Value>, )

Posts an expectation for successive reads to register R returning values.

Models deterministic polling sequences (e.g. status polling until ready):

  • Requires the driver to read each value in the sequence at least once in order.
  • Once the sequence is exhausted, subsequent reads return the last value.
  • The expectation automatically retires when the driver performs the next non-matching access (e.g., writing the next configuration register).
§Panics

Panics if values is empty.

Source

pub fn poll_indefinitely<R: ReadableRegister>(&mut self, busy_value: R::Value)

Posts an expectation for reading busy_value from register R one or more times.

Models indefinite polling retry loops (e.g. testing driver timeout and error recovery):

  • Requires the driver to read busy_value at least once.
  • Returns busy_value for any subsequent reads while the driver executes its retry loop.
  • The expectation automatically retires when the driver ceases polling and initiates timeout recovery (e.g., writing a reset command).
Source

pub fn poll_indexed<R: ReadableIndexedRegister>( &mut self, index: usize, values: impl IntoIterator<Item = R::Value>, )

Posts an expectation for reading valuesfrom registerRatindex`.

The byte offset is R::BASE_OFFSET + index * R::STRIDE.

§Panics

Panics if index is greater than or equal to R::COUNT, or if values is empty.

Source

pub fn poll_indefinitely_indexed<R: ReadableIndexedRegister>( &mut self, index: usize, busy_value: R::Value, )

Posts an expectation for reading busy_value from register R at index one or more times.

The byte offset is R::BASE_OFFSET + index * R::STRIDE.

§Panics

Panics if index is greater than or equal to R::COUNT.

Source

pub fn at(&mut self, offset: usize) -> RawOffsetTraceBuilder<'a, '_>

Selects a raw byte offset for declaring expectations on un-typed MMIO registers.

Returns a RawOffsetTraceBuilder providing width-annotated access methods (read8..read64, write8..write64, poll8..poll64, and poll_indefinitely8..poll_indefinitely64).

Source

pub fn write_barrier(&mut self)

Posts an expectation for an MMIO memory write barrier (mmio::Mmio::write_barrier).

Trait Implementations§

Source§

impl<'a> Debug for ExpectedTraceBuilder<'a>

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.