Skip to main content

Mountain/RPC/CocoonService/Provider/
ProvideTypeHierarchySubtypes.rs

1
2//! Forward a type hierarchy subtypes request to the registered provider.
3
4use serde_json::json;
5use tonic::{Response, Status};
6use CommonLibrary::LanguageFeature::LanguageFeatureProviderRegistry::LanguageFeatureProviderRegistry;
7
8use crate::{
9	RPC::CocoonService::CocoonServiceImpl,
10	Vine::Generated::{ProvideTypeHierarchyRequest, ProvideTypeHierarchyResponse},
11	dev_log,
12};
13
14pub async fn Fn(
15	Service:&CocoonServiceImpl,
16
17	Request:ProvideTypeHierarchyRequest,
18) -> Result<Response<ProvideTypeHierarchyResponse>, Status> {
19	dev_log!("cocoon", "[CocoonService] Providing type hierarchy subtypes");
20
21	let ItemDTO = json!({
22		"name": Request.item.as_ref().map(|I| I.name.as_str()).unwrap_or(""),
23		"uri": Request.uri.as_ref().map(|U| U.value.as_str()).unwrap_or(""),
24	});
25
26	match Service.environment.ProvideTypeHierarchySubtypes(ItemDTO).await {
27		Ok(_) => Ok(Response::new(<ProvideTypeHierarchyResponse>::default())),
28
29		Err(Error) => Err(Status::internal(format!("type hierarchy subtypes failed: {}", Error))),
30	}
31}