Mountain/RPC/CocoonService/GenericRequest/FileSystem/
ReadFileUri.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 Uri = Params
10 .get("uri")
11 .and_then(|V| V.as_str())
12 .or_else(|| Params.as_str())
13 .unwrap_or("")
14 .replace("file://", "");
15
16 match tokio::fs::read(&Uri).await {
17 Ok(Content) => super::OkResponse(RequestId, &Content),
18
19 Err(Error) => super::ErrResponse(RequestId, -32000, format!("readFile: {}", Error)),
20 }
21}