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>
impl<'a> ExpectedTraceBuilder<'a>
Sourcepub fn read<R: ReadableRegister>(&mut self, value: R::Value)
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.
Sourcepub fn write<R: WritableRegister>(&mut self, value: R::Value)
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.
Sourcepub fn read_indexed<R: ReadableIndexedRegister>(
&mut self,
index: usize,
value: R::Value,
)
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.
Sourcepub fn write_indexed<R: WritableIndexedRegister>(
&mut self,
index: usize,
value: R::Value,
)
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.
Sourcepub fn poll<R: ReadableRegister>(
&mut self,
values: impl IntoIterator<Item = R::Value>,
)
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.
Sourcepub fn poll_indefinitely<R: ReadableRegister>(&mut self, busy_value: R::Value)
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_valueat least once. - Returns
busy_valuefor 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).
Sourcepub fn poll_indexed<R: ReadableIndexedRegister>(
&mut self,
index: usize,
values: impl IntoIterator<Item = R::Value>,
)
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.
Sourcepub fn poll_indefinitely_indexed<R: ReadableIndexedRegister>(
&mut self,
index: usize,
busy_value: R::Value,
)
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.
Sourcepub fn at(&mut self, offset: usize) -> RawOffsetTraceBuilder<'a, '_>
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).
Sourcepub fn write_barrier(&mut self)
pub fn write_barrier(&mut self)
Posts an expectation for an MMIO memory write barrier (mmio::Mmio::write_barrier).