pub trait InputHandler: AsRcAny {
    // Required methods
    fn handle_input_event<'async_trait>(
        self: Rc<Self>,
        input_event: InputEvent
    ) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>
       where Self: 'async_trait;
    fn set_handler_healthy(self: Rc<Self>);
    fn set_handler_unhealthy(self: Rc<Self>, msg: &str);

    // Provided method
    fn get_name(&self) -> &'static str { ... }
}
Expand description

An InputHandler dispatches InputEvents to an external service. It maintains service connections necessary to handle the events.

For example, an [ImeInputHandler] holds a proxy to IME and keyboard services.

InputHandlers process individual input events through [handle_input_event()], which can produce multiple events as an outcome. If the InputHandler sends an [InputEvent] to a service that consumes the event, then the InputHandler updates the [InputEvent.handled] accordingly.

§Notes

  • Callers should not invoke [handle_input_event()] concurrently since sequences of events must be preserved. The state created by event n may affect the interpretation of event n+1.
  • Callees should avoid blocking unnecessarily, as that prevents InputEvents from propagating to downstream handlers in a timely manner. See further discussion of blocking.

Required Methods§

source

fn handle_input_event<'async_trait>( self: Rc<Self>, input_event: InputEvent ) -> Pin<Box<dyn Future<Output = Vec<InputEvent>> + 'async_trait>>
where Self: 'async_trait,

Returns a vector of InputEvents to propagate to the next InputHandler.

  • The vector may be empty if, e.g., the handler chose to buffer the event.
  • The vector may have multiple events if, e.g.,
    • the handler chose to release previously buffered events, or
    • the handler unpacked a single event into multiple events
§Parameters

input_event: The InputEvent to be handled.

source

fn set_handler_healthy(self: Rc<Self>)

source

fn set_handler_unhealthy(self: Rc<Self>, msg: &str)

Provided Methods§

source

fn get_name(&self) -> &'static str

Returns the name of the input handler.

The default implementation returns the name of the struct implementing the trait.

Implementors§

source§

impl InputHandler for MouseInjectorHandler

source§

impl<F: FnMut() -> Time + 'static> InputHandler for InspectHandler<F>

source§

impl<T> InputHandler for LightSensorHandler<T>
where T: Calibrate + 'static,

source§

impl<T> InputHandler for T