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