reactive_graph_behaviour_service_api/
relation_behaviour_manager.rs

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