reactive_graph_behaviour_service_api/
entity_behaviour_registry.rs1use std::sync::Arc;
2
3use async_trait::async_trait;
4use springtime_di::injectable;
5use uuid::Uuid;
6
7use reactive_graph_behaviour_model_api::prelude::*;
8use reactive_graph_graph::EntityTypeId;
9use reactive_graph_lifecycle::Lifecycle;
10use reactive_graph_reactive_model_impl::ReactiveEntity;
11
12#[injectable]
13#[async_trait]
14pub trait EntityBehaviourRegistry: Send + Sync + Lifecycle {
15 fn register(&self, entity_behaviour_ty: EntityBehaviourTypeId, factory: Arc<dyn BehaviourFactory<Uuid, ReactiveEntity> + Send + Sync>);
17
18 fn unregister(&self, entity_behaviour_ty: &EntityBehaviourTypeId);
20
21 fn get_all(&self) -> Vec<EntityBehaviourTypeId>;
23
24 fn get(&self, entity_ty: &EntityTypeId) -> Vec<Arc<dyn BehaviourFactory<Uuid, ReactiveEntity> + Send + Sync>>;
26
27 fn get_factory_by_behaviour_type(&self, behaviour_ty: &BehaviourTypeId) -> Option<Arc<dyn BehaviourFactory<Uuid, ReactiveEntity> + Send + Sync>>;
29
30 fn get_behaviour_types(&self, entity_ty: &EntityTypeId) -> Vec<EntityBehaviourTypeId>;
32
33 fn get_by_behaviour_type(&self, behaviour_ty: &BehaviourTypeId) -> Option<EntityBehaviourTypeId>;
35
36 fn count(&self) -> usize;
38}