reactive_graph_plugin_delegates/
component_import_export_manager_impl.rs

1use async_trait::async_trait;
2use std::sync::Arc;
3
4use reactive_graph_graph::Component;
5use reactive_graph_graph::ComponentTypeId;
6use reactive_graph_type_system_api::ComponentExportError;
7use reactive_graph_type_system_api::ComponentImportError;
8
9pub struct ComponentImportExportManagerDelegate {
10    component_import_export_manager: Arc<dyn reactive_graph_type_system_api::ComponentImportExportManager + Send + Sync>,
11}
12
13impl ComponentImportExportManagerDelegate {
14    pub fn new(component_manager: Arc<dyn reactive_graph_type_system_api::ComponentImportExportManager + Send + Sync>) -> Self {
15        Self {
16            component_import_export_manager: component_manager,
17        }
18    }
19}
20
21#[async_trait]
22impl reactive_graph_plugin_api::ComponentImportExportManager for ComponentImportExportManagerDelegate {
23    async fn import(&self, path: &str) -> Result<Component, ComponentImportError> {
24        self.component_import_export_manager.import(path).await
25    }
26
27    async fn export(&self, ty: &ComponentTypeId, path: &str) -> Result<(), ComponentExportError> {
28        self.component_import_export_manager.export(ty, path).await
29    }
30}