sl4f_lib/file/
commands.rs1use crate::file::facade::FileFacade;
6use crate::file::types::FileMethod;
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 FileFacade {
14 async fn handle_request(&self, method: String, args: Value) -> Result<Value, Error> {
15 match method.parse()? {
16 FileMethod::DeleteFile => {
17 let result = self.delete_file(args).await?;
18 Ok(to_value(result)?)
19 }
20 FileMethod::MakeDir => {
21 let result = self.make_dir(args).await?;
22 Ok(to_value(result)?)
23 }
24 FileMethod::ReadFile => {
25 let result = self.read_file(args).await?;
26 Ok(to_value(result)?)
27 }
28 FileMethod::WriteFile => {
29 let result = self.write_file(args).await?;
30 Ok(to_value(result)?)
31 }
32 FileMethod::Stat => {
33 let result = self.stat(args).await?;
34 Ok(to_value(result)?)
35 }
36 }
37 }
38}