pub struct FakeHal { /* private fields */ }Expand description
An in-memory fake Hal for tests and simulators.
Echoes writes back as state, and fakes joint actuation by mirroring any
*.target_position write to the corresponding *.position (so a consumer
that writes a target sees the measured position follow). Cheaply cloneable;
clones share the same state. (Backed by State,
the trivial owned state type.)
Implementations§
Source§impl FakeHal
impl FakeHal
pub fn new() -> Self
pub fn with_description(description: HalDescription) -> Self
pub fn set_model_glb(&self, glb: Vec<u8>)
Trait Implementations§
Source§impl Hal for FakeHal
impl Hal for FakeHal
Source§fn try_send(&self, changes: &StateChange)
fn try_send(&self, changes: &StateChange)
Synchronous, immediate apply — the fake never blocks, so it needs no task of its own (unlike a real HTTP/DDS HAL).
Source§fn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HalDescription> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn describe<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HalDescription> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Describe the device (model family, versions).
Source§fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Key],
) -> Pin<Box<dyn Future<Output = HalResult<Vec<Option<Value>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [Key],
) -> Pin<Box<dyn Future<Output = HalResult<Vec<Option<Value>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read the current values for the given keys. Each entry is
None if the
key is unset/absent (further nesting lives inside Value).Source§fn read_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HalResult<State>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HalResult<State>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Read everything the HAL currently exposes.
Source§fn write<'life0, 'async_trait>(
&'life0 self,
changes: StateChange,
) -> Pin<Box<dyn Future<Output = HalResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write<'life0, 'async_trait>(
&'life0 self,
changes: StateChange,
) -> Pin<Box<dyn Future<Output = HalResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Apply actuator/state changes. Observers of
updates see
the resulting changes.Source§fn updates(&self) -> UpdatesStream
fn updates(&self) -> UpdatesStream
A feed of changes the hardware reports (sensors, mirrored actuation, …).
Each call yields an independent, owned stream; the consumer that takes
it is its one poller (natively the runtime’s
run select, on the web
the per-frame sweep).Auto Trait Implementations§
impl Freeze for FakeHal
impl RefUnwindSafe for FakeHal
impl Send for FakeHal
impl Sync for FakeHal
impl Unpin for FakeHal
impl UnsafeUnpin for FakeHal
impl UnwindSafe for FakeHal
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