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.
InputHandler
s 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
InputEvent
s from propagating to downstream handlers in a timely manner. See further discussion of blocking.
Required Methods§
Sourcefn 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 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.