DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/RPC/CocoonService/Extension/
GetExtension.rs1use tonic::{Response, Status};
5use CommonLibrary::ExtensionManagement::ExtensionManagementService::ExtensionManagementService;
6
7use crate::{
8 RPC::CocoonService::CocoonServiceImpl,
9 Vine::Generated::{ExtensionInfo, GetExtensionRequest, GetExtensionResponse},
10 dev_log,
11};
12
13pub async fn Fn(
14 Service:&CocoonServiceImpl,
15
16 Request:GetExtensionRequest,
17) -> Result<Response<GetExtensionResponse>, Status> {
18 dev_log!("cocoon", "[CocoonService] get_extension: {}", Request.extension_id);
19
20 let Found = Service
21 .environment
22 .GetExtension(Request.extension_id.clone())
23 .await
24 .ok()
25 .flatten();
26
27 let Info = Found.map(|Value| {
28 ExtensionInfo {
29 id:Request.extension_id,
30 display_name:Value.get("Name").and_then(|V| V.as_str()).unwrap_or("").to_string(),
31 version:Value.get("Version").and_then(|V| V.as_str()).unwrap_or("").to_string(),
32 is_active:true,
33 extension_path:Value
34 .get("ExtensionLocation")
35 .and_then(|V| V.as_str())
36 .unwrap_or("")
37 .to_string(),
38 }
39 });
40
41 Ok(Response::new(GetExtensionResponse { extension:Info }))
42}