pub struct RecordingActuator<C> { /* private fields */ }Expand description
An actuator that records every command instead of driving hardware.
This stands in for a relay, a valve, or a motor in a hardware-free test: it
implements the core [Actuator] trait and keeps an ordered log of every command
applied to it, so a test can assert what a control loop decided to do. Take a
log handle before moving the actuator into a Node,
then read the commands back through it afterwards.
§Examples
use pamoja_core::Actuator;
use pamoja_sim::RecordingActuator;
let mut relay = RecordingActuator::new();
let log = relay.log();
relay.apply(true).await?;
relay.apply(false).await?;
assert_eq!(log.commands(), vec![true, false]);Implementations§
Source§impl<C> RecordingActuator<C>
impl<C> RecordingActuator<C>
Sourcepub fn log(&self) -> ActuatorLog<C>
pub fn log(&self) -> ActuatorLog<C>
Returns a handle that reads this actuator’s command log.
The handle shares the same underlying log, so commands applied after it is taken are still visible through it.
§Returns
An ActuatorLog over the same recorded commands.
Trait Implementations§
Source§impl<C> Actuator for RecordingActuator<C>
impl<C> Actuator for RecordingActuator<C>
Source§impl<C: Clone> Clone for RecordingActuator<C>
impl<C: Clone> Clone for RecordingActuator<C>
Source§fn clone(&self) -> RecordingActuator<C>
fn clone(&self) -> RecordingActuator<C>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<C: Debug> Debug for RecordingActuator<C>
impl<C: Debug> Debug for RecordingActuator<C>
Auto Trait Implementations§
impl<C> Freeze for RecordingActuator<C>
impl<C> RefUnwindSafe for RecordingActuator<C>
impl<C> Send for RecordingActuator<C>where
C: Send,
impl<C> Sync for RecordingActuator<C>where
C: Send,
impl<C> Unpin for RecordingActuator<C>
impl<C> UnsafeUnpin for RecordingActuator<C>
impl<C> UnwindSafe for RecordingActuator<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more