Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/RPC/CocoonService/Extension/
GetAllExtensions.rs

1//! Return every scanned extension projected into the gRPC `ExtensionInfo`
2//! shape.
3
4use tonic::{Response, Status};
5use CommonLibrary::ExtensionManagement::ExtensionManagementService::ExtensionManagementService;
6
7use crate::{
8	RPC::CocoonService::CocoonServiceImpl,
9	Vine::Generated::{Empty, ExtensionInfo, GetAllExtensionsResponse},
10};
11
12pub async fn Fn(Service:&CocoonServiceImpl, _Request:Empty) -> Result<Response<GetAllExtensionsResponse>, Status> {
13	let Extensions = Service.environment.GetExtensions().await.unwrap_or_default();
14
15	let List = Extensions
16		.iter()
17		.map(|Value| {
18			ExtensionInfo {
19				id:Value.get("Identifier").and_then(|V| V.as_str()).unwrap_or("").to_string(),
20				display_name:Value.get("Name").and_then(|V| V.as_str()).unwrap_or("").to_string(),
21				version:Value.get("Version").and_then(|V| V.as_str()).unwrap_or("").to_string(),
22				is_active:true,
23				extension_path:Value
24					.get("ExtensionLocation")
25					.and_then(|V| V.as_str())
26					.unwrap_or("")
27					.to_string(),
28			}
29		})
30		.collect();
31
32	Ok(Response::new(GetAllExtensionsResponse { extensions:List }))
33}