reactive_graph_behaviour_service_api/
entity_behaviour_manager.rs

1use async_trait::async_trait;
2use springtime_di::injectable;
3use uuid::Uuid;
4
5use reactive_graph_behaviour_model_api::BehaviourTransitionError;
6use reactive_graph_behaviour_model_api::BehaviourTypeId;
7use reactive_graph_lifecycle::Lifecycle;
8use reactive_graph_reactive_model_impl::ReactiveEntity;
9
10#[injectable]
11#[async_trait]
12pub trait EntityBehaviourManager: Send + Sync + Lifecycle {
13    /// Adds all behaviours to the given reactive entity instance.
14    fn add_behaviours(&self, entity_instance: ReactiveEntity);
15
16    /// Creates and adds the given behaviour to the given reactive entity instance.
17    fn add_behaviour(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId);
18
19    /// Removes the given behaviour from the given reactive entity instance.
20    fn remove_behaviour(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId);
21
22    /// Removes all behaviours from the given reactive entity instance.
23    fn remove_behaviours(&self, entity_instance: ReactiveEntity);
24
25    /// Removes all behaviours from the reactive entity instance with the given id.
26    fn remove_behaviours_by_id(&self, id: &Uuid);
27
28    /// Removes all behaviours of the given behaviour type.
29    fn remove_behaviours_by_behaviour(&self, behaviour_ty: &BehaviourTypeId);
30
31    /// Returns true, if the entity instance has the given behaviour.
32    fn has(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> bool;
33
34    /// Returns the behaviours of the given entity instance.
35    fn get_all(&self, entity_instance: ReactiveEntity) -> Vec<BehaviourTypeId>;
36
37    /// Returns the entity instances with the given behaviour.
38    fn get_instances_by_behaviour(&self, ty: &BehaviourTypeId) -> Vec<ReactiveEntity>;
39
40    /// Connect
41    fn connect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
42
43    /// Disconnect
44    fn disconnect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
45
46    /// Reconnect
47    fn reconnect(&self, entity_instance: ReactiveEntity, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
48}