Skip to main content

Hal

Trait Hal 

Source
pub trait Hal: Send + Sync {
    // Required methods
    fn describe<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = HalDescription> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: '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;
    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 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 try_send(&self, changes: &StateChange);
    fn updates(&self) -> UpdatesStream;
}
Expand description

The Hardware Abstraction Layer: the boundary to a device.

Interior-mutable (&self): the methods take shared references, so an implementation that hands sibling handles to an observer keeps working — the runtime still owns its HAL by value.

Required Methods§

Source

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,

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,

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,

Apply actuator/state changes. Observers of updates see the resulting changes.

Source

fn try_send(&self, changes: &StateChange)

Push actuator/state changes toward the hardware immediately, without blocking — the outbound counterpart to the updates sensor feed, and the shape the synchronous runtime step calls directly (mirroring Bridge::try_send).

Must not block. A HAL whose apply is truly immediate (an in-memory fake, a cache write) applies here directly; a HAL that performs real async I/O (HTTP, DDS) enqueues onto its own internal task and returns. There is deliberately no default: every implementation decides how its hardware absorbs a non-blocking push.

Source

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).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§