Skip to main content

RecordingActuator

Struct RecordingActuator 

Source
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>

Source

pub fn new() -> Self

Creates an actuator with an empty command log.

§Returns

A recording actuator.

Source

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>

Source§

type Command = C

The command accepted by a single application, for example a setpoint.
Source§

async fn apply(&mut self, command: C) -> Result<()>

Applies a command to the actuator. Read more
Source§

impl<C: Clone> Clone for RecordingActuator<C>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for RecordingActuator<C>

Source§

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

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

impl<C> Default for RecordingActuator<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.