Mountain/RPC/CocoonService/GenericRequest/FileSystem/
ReadFile.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::Value;
4use tonic::Response;
5
6use crate::Vine::Generated::GenericResponse;
7
8pub async fn Fn(RequestId:u64, Params:Value) -> Response<GenericResponse> {
9 let Path = Params
10 .as_str()
11 .or_else(|| Params.get("path").and_then(|V| V.as_str()))
12 .unwrap_or("");
13
14 match tokio::fs::read(Path).await {
15 Ok(Content) => super::OkResponse(RequestId, &Content),
16
17 Err(Error) => super::ErrResponse(RequestId, -32000, format!("fs.readFile: {}", Error)),
18 }
19}