Skip to main content

InputSource

Trait InputSource 

Source
pub trait InputSource {
    // Required method
    fn poll_event(&mut self) -> Option<InputEvent>;
}
Expand description

A non-blocking, drain-style source of InputEvents.

The contract is deliberately poll-based rather than async or callback-driven so one trait serves a bare-metal frame loop and a Linux host alike. A display/event-loop thread drains the source once per frame and folds the events into its backend, honoring the single-threaded UI rule: the UI guest is never called from a device callback or worker thread, only at a frame boundary.

Expected implementors:

  • Linux: a libinput/evdev reader thread pushing into a bounded channel; poll_event pops from the channel.
  • Bare metal, local: an embedded-hal touch/GPIO/encoder driver decoded into events on the same core.
  • Bare metal, over IPC: a Consortium IPC receiver whose payloads are codec-decoded InputEvents produced by a real-time core.

Required Methods§

Source

fn poll_event(&mut self) -> Option<InputEvent>

Returns the next pending event, or None when the source is drained for this poll. Must not block.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§