Skip to main content

Mountain/RPC/CocoonService/Provider/
ProvideTypeHierarchySubtypes.rs

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