input_pipeline/
observe_fake_events_input_handler.rsuse crate::{input_device, input_handler};
use async_trait::async_trait;
use futures::channel::mpsc::Sender;
use std::cell::RefCell;
use std::rc::Rc;
pub struct ObserveFakeEventsInputHandler {
event_sender: RefCell<Sender<input_device::InputEvent>>,
}
#[cfg(test)]
impl ObserveFakeEventsInputHandler {
pub fn new(event_sender: Sender<input_device::InputEvent>) -> Rc<Self> {
Rc::new(ObserveFakeEventsInputHandler { event_sender: RefCell::new(event_sender) })
}
}
#[async_trait(?Send)]
impl input_handler::InputHandler for ObserveFakeEventsInputHandler {
async fn handle_input_event(
self: Rc<Self>,
input_event: input_device::InputEvent,
) -> Vec<input_device::InputEvent> {
match self.event_sender.borrow_mut().try_send(input_event.clone()) {
Err(_) => assert!(false),
_ => {}
};
vec![input_event]
}
fn set_handler_healthy(self: std::rc::Rc<Self>) {
}
fn set_handler_unhealthy(self: std::rc::Rc<Self>, _msg: &str) {
}
}