Skip to main content

Mountain/RPC/CocoonService/Provider/
ProvideTypeHierarchySupertypes.rs

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