sl4f_lib/temperature/
commands.rs1use crate::server::Facade;
6use crate::temperature::facade::TemperatureFacade;
7use anyhow::{bail, Error};
8use async_trait::async_trait;
9use serde_json::{to_value, Value};
10
11#[async_trait(?Send)]
12impl Facade for TemperatureFacade {
13 async fn handle_request(&self, method: String, args: Value) -> Result<Value, Error> {
14 match method.as_ref() {
15 "GetTemperatureCelsius" => {
16 let result = self.get_temperature_celsius(args).await?;
17 Ok(to_value(result)?)
18 }
19 "StartLogging" => {
20 let result = self.start_logging(args).await?;
21 Ok(to_value(result)?)
22 }
23 "StartLoggingForever" => {
24 let result = self.start_logging_forever(args).await?;
25 Ok(to_value(result)?)
26 }
27 "StopLogging" => {
28 let result = self.stop_logging().await?;
29 Ok(to_value(result)?)
30 }
31 _ => bail!("Invalid TemperatureFacade FIDL method: {:?}", method),
32 }
33 }
34}