input_pipeline/
observe_fake_events_input_handler.rs1use crate::{input_device, input_handler};
6use async_trait::async_trait;
7use futures::channel::mpsc::Sender;
8use std::cell::RefCell;
9use std::rc::Rc;
10
11pub struct ObserveFakeEventsInputHandler {
14 event_sender: RefCell<Sender<input_device::InputEvent>>,
16}
17
18#[cfg(test)]
19impl ObserveFakeEventsInputHandler {
20 pub fn new(event_sender: Sender<input_device::InputEvent>) -> Rc<Self> {
21 Rc::new(ObserveFakeEventsInputHandler { event_sender: RefCell::new(event_sender) })
22 }
23}
24
25#[async_trait(?Send)]
26impl input_handler::InputHandler for ObserveFakeEventsInputHandler {
27 async fn handle_input_event(
28 self: Rc<Self>,
29 input_event: input_device::InputEvent,
30 ) -> Vec<input_device::InputEvent> {
31 match self.event_sender.borrow_mut().try_send(input_event.clone()) {
32 Err(_) => assert!(false),
33 _ => {}
34 };
35
36 vec![input_event]
37 }
38
39 fn set_handler_healthy(self: std::rc::Rc<Self>) {
40 }
42
43 fn set_handler_unhealthy(self: std::rc::Rc<Self>, _msg: &str) {
44 }
46}