reactive_graph_std_taxonomy/
plugin.rs1use reactive_graph_plugin_api::prelude::plugin::*;
2use reactive_graph_plugin_api::prelude::providers::*;
3
4export_plugin!({
5 "dependencies": [
6 { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }
7 ]
8});
9
10#[injectable]
11pub trait TaxonomyPlugin: Plugin + Send + Sync {}
12
13#[derive(Component)]
14pub struct TaxonomyPluginImpl {
15 component_provider: Arc<dyn TypeProvider<Components> + Send + Sync>,
16
17 #[component(default = "component_provider_registry")]
18 component_provider_registry: Arc<dyn ComponentProviderRegistry + Send + Sync>,
19
20 entity_types_provider: Arc<dyn TypeProvider<EntityTypes> + Send + Sync>,
21
22 #[component(default = "entity_types_provider_registry")]
23 entity_type_provider_registry: Arc<dyn EntityTypeProviderRegistry + Send + Sync>,
24
25 relation_types_provider: Arc<dyn TypeProvider<RelationTypes> + Send + Sync>,
26
27 #[component(default = "relation_types_provider_registry")]
28 relation_type_provider_registry: Arc<dyn RelationTypeProviderRegistry + Send + Sync>,
29}
30
31#[async_trait]
32#[component_alias]
33impl Plugin for TaxonomyPluginImpl {
34 async fn activate(&self) -> Result<(), PluginActivationError> {
35 self.component_provider_registry.register_provider(self.component_provider.clone()).await;
36 self.entity_type_provider_registry.register_provider(self.entity_types_provider.clone()).await;
37 self.relation_type_provider_registry
38 .register_provider(self.relation_types_provider.clone())
39 .await;
40 Ok(())
41 }
42
43 async fn deactivate(&self) -> Result<(), PluginDeactivationError> {
44 self.relation_type_provider_registry
45 .unregister_provider(self.relation_types_provider.id())
46 .await;
47 self.entity_type_provider_registry.unregister_provider(self.entity_types_provider.id()).await;
48 self.component_provider_registry.unregister_provider(self.component_provider.id()).await;
49 Ok(())
50 }
51}