sl4f_lib/device/
commands.rs1use crate::device::facade::DeviceFacade;
6use crate::device::types::DeviceMethod;
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 DeviceFacade {
14 async fn handle_request(&self, method: String, _args: Value) -> Result<Value, Error> {
15 match method.parse()? {
16 DeviceMethod::GetDeviceName => {
17 let result = self.get_device_name().await?;
18 Ok(to_value(result)?)
19 }
20 DeviceMethod::GetProduct => {
21 let result = self.get_product().await?;
22 Ok(to_value(result)?)
23 }
24 DeviceMethod::GetVersion => {
25 let result = self.get_version().await?;
26 Ok(to_value(result)?)
27 }
28 }
29 }
30}