sl4f_lib/weave/
commands.rs1use crate::server::Facade;
6use crate::weave::facade::WeaveFacade;
7use crate::weave::types::WeaveMethod;
8use anyhow::Error;
9use async_trait::async_trait;
10use serde_json::{to_value, Value};
11
12#[async_trait(?Send)]
13impl Facade for WeaveFacade {
14 async fn handle_request(&self, method: String, args: Value) -> Result<Value, Error> {
15 Ok(match method.parse()? {
16 WeaveMethod::GetPairingCode => to_value(self.get_pairing_code().await?),
17 WeaveMethod::GetPairingState => to_value(self.get_pairing_state().await?),
18 WeaveMethod::GetQrCode => to_value(self.get_qr_code().await?),
19 WeaveMethod::ResetConfig => to_value(self.reset_config(args).await?),
20 }?)
21 }
22}