pub struct MapCommand<A, F, C> { /* private fields */ }Expand description
An actuator whose commands are converted before they reach the part.
Created by Actuator::map_command. The function runs on every command, so a part
that takes a pulse width or a duty can be driven by a bool, an angle, or a
percentage, whichever the caller has.
§Examples
use pamoja_core::{Actuator, Result};
struct Pump {
duty: u8,
}
impl Actuator for Pump {
type Command = u8;
async fn apply(&mut self, duty: u8) -> Result<()> {
self.duty = duty;
Ok(())
}
}
// A profile drives the pump as on or off; on means full speed.
let mut switch = Pump { duty: 0 }.map_command(|on: bool| if on { 100 } else { 0 });
switch.apply(true).await?;
assert_eq!(switch.inner().duty, 100);Implementations§
Source§impl<A, F, C> MapCommand<A, F, C>
impl<A, F, C> MapCommand<A, F, C>
Trait Implementations§
Source§impl<A, F, C> Actuator for MapCommand<A, F, C>
impl<A, F, C> Actuator for MapCommand<A, F, C>
Auto Trait Implementations§
impl<A, F, C> Freeze for MapCommand<A, F, C>
impl<A, F, C> RefUnwindSafe for MapCommand<A, F, C>where
A: RefUnwindSafe,
F: RefUnwindSafe,
impl<A, F, C> Send for MapCommand<A, F, C>
impl<A, F, C> Sync for MapCommand<A, F, C>
impl<A, F, C> Unpin for MapCommand<A, F, C>
impl<A, F, C> UnsafeUnpin for MapCommand<A, F, C>where
A: UnsafeUnpin,
F: UnsafeUnpin,
impl<A, F, C> UnwindSafe for MapCommand<A, F, C>where
A: UnwindSafe,
F: UnwindSafe,
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