Skip to main content

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;
6use ::Vine::Generated::{Empty, ExtensionInfo, GetAllExtensionsResponse};
7
8use crate::RPC::CocoonService::CocoonServiceImpl;
9
10pub async fn Fn(Service:&CocoonServiceImpl, _Request:Empty) -> Result<Response<GetAllExtensionsResponse>, Status> {
11	let Extensions = Service.environment.GetExtensions().await.unwrap_or_default();
12
13	let List = Extensions
14		.iter()
15		.map(|Value| {
16			ExtensionInfo {
17				id:Value.get("Identifier").and_then(|V| V.as_str()).unwrap_or("").to_string(),
18				display_name:Value.get("Name").and_then(|V| V.as_str()).unwrap_or("").to_string(),
19				version:Value.get("Version").and_then(|V| V.as_str()).unwrap_or("").to_string(),
20				is_active:true,
21				extension_path:Value
22					.get("ExtensionLocation")
23					.and_then(|V| V.as_str())
24					.unwrap_or("")
25					.to_string(),
26			}
27		})
28		.collect();
29
30	Ok(Response::new(GetAllExtensionsResponse { extensions:List }))
31}