Skip to main content

HidBackend

Trait HidBackend 

Source
pub trait HidBackend: Send + Sync {
    // Required methods
    fn enumerate<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<NodeInfo>, BackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn enumerate_hidpp<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<NodeInfo>, BackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn open_hidpp<'life0, 'life1, 'async_trait>(
        &'life0 self,
        node: &'life1 NodeInfo,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Arc<HidppChannel>>, BackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn open_raw_writer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        node: &'life1 NodeInfo,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn RawWriter>, BackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn watch(&self) -> Result<HotplugStream, BackendError>;
}
Expand description

The HID stack beneath OpenLogi’s HID++ layer.

One implementation per host HID API. Everything above it — enumeration policy, the probe, the write layer, capture sessions — is expressed against this trait and holds none of the backend’s own types, which is what lets a second implementation (a scripted device tree in tests, WebHID under wasm) drop in without touching that code.

Opening is only defined for a node a previous Self::enumerate reported: a backend may hold OS handles from that enumeration rather than re-finding the node, so an unknown NodeInfo is BackendError::Disconnected.

Required Methods§

Source

fn enumerate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<NodeInfo>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Every HID node the host currently reports.

Source

fn enumerate_hidpp<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<NodeInfo>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The subset of Self::enumerate that can carry HID++ traffic.

Separate from filtering in the caller because part of the answer is platform knowledge the backend owns — on Linux the hid-logitech-dj driver publishes a per-device child node that exposes the same vendor collection as its receiver but must never be addressed directly.

Source

fn open_hidpp<'life0, 'life1, 'async_trait>( &'life0 self, node: &'life1 NodeInfo, ) -> Pin<Box<dyn Future<Output = Result<Option<Arc<HidppChannel>>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open node as a HID++ channel, or None if it does not speak HID++.

The backend owns the framing details behind this: which report widths the node carries, and on Windows the pairing of the separate short- and long-report interfaces into one channel.

Source

fn open_raw_writer<'life0, 'life1, 'async_trait>( &'life0 self, node: &'life1 NodeInfo, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn RawWriter>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open node for raw output reports.

Source

fn watch(&self) -> Result<HotplugStream, BackendError>

Subscribe to node connect/disconnect events.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§