sl4f_lib/modular/
commands.rs1use crate::modular::facade::ModularFacade;
6use crate::modular::types::ModularMethod;
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 ModularFacade {
14 async fn handle_request(&self, method: String, args: Value) -> Result<Value, Error> {
15 match method.parse()? {
16 ModularMethod::RestartSession => {
17 let result = self.restart_session().await?;
18 Ok(to_value(result)?)
19 }
20 ModularMethod::StartBasemgr => {
21 let result = self.start_session(args).await?;
22 Ok(to_value(result)?)
23 }
24 ModularMethod::KillBasemgr => {
25 let result = self.stop_session().await?;
26 Ok(to_value(result)?)
27 }
28 ModularMethod::IsBasemgrRunning => {
29 let result = self.is_session_running().await?;
30 Ok(to_value(result)?)
31 }
32 }
33 }
34}