sl4f_lib/input/
commands.rs1use crate::input::facade::InputFacade;
6use crate::input::types::InputMethod;
7use crate::server::Facade;
8use anyhow::Error;
9use async_trait::async_trait;
10use serde_json::{to_value, Value};
11
12#[async_trait(?Send)]
13impl Facade for InputFacade {
14 async fn handle_request(&self, method: String, args: Value) -> Result<Value, Error> {
15 match method.parse()? {
16 InputMethod::Tap => {
17 let result = self.tap(args).await?;
18 Ok(to_value(result)?)
19 }
20 InputMethod::MultiFingerTap => {
21 let result = self.multi_finger_tap(args).await?;
22 Ok(to_value(result)?)
23 }
24 InputMethod::Swipe => {
25 let result = self.swipe(args).await?;
26 Ok(to_value(result)?)
27 }
28 InputMethod::MultiFingerSwipe => {
29 let result = self.multi_finger_swipe(args).await?;
30 Ok(to_value(result)?)
31 }
32 InputMethod::Text => {
33 let result = self.text(args).await?;
34 Ok(to_value(result)?)
35 }
36 InputMethod::KeyPress => {
37 let result = self.key_press(args).await?;
38 Ok(to_value(result)?)
39 }
40 InputMethod::KeyEvents => {
41 let result = self.key_events(args).await?;
42 Ok(to_value(result)?)
43 }
44 }
45 }
46}