reactive_graph_behaviour_service_api/
relation_component_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_behaviour_model_api::ComponentBehaviourTypeId;
7use reactive_graph_graph::Component;
8use reactive_graph_graph::RelationInstanceId;
9use reactive_graph_lifecycle::Lifecycle;
10use reactive_graph_reactive_model_impl::ReactiveRelation;
11
12#[injectable]
13#[async_trait]
14pub trait RelationComponentBehaviourManager: Send + Sync + Lifecycle {
15    /// Adds new behaviours to the given relation instance.
16    fn add_behaviours_to_relation(&self, relation_instance: ReactiveRelation);
17
18    /// Possibly adds new behaviour to the given relation instance's component
19    fn add_behaviours_to_relation_component(&self, relation_instance: ReactiveRelation, component: Component);
20
21    /// Creates and adds the given behaviour to the given reactive entity instance's component.
22    fn add_behaviour_to_relation_component(&self, relation_instance: ReactiveRelation, component_behaviour_ty: &ComponentBehaviourTypeId);
23
24    /// Removes the given behaviour from the given reactive relation instance.
25    fn remove_behaviour_from_relation(&self, relation_instance: ReactiveRelation, behaviour_ty: &BehaviourTypeId);
26
27    /// Removes behaviours from the given relation instance.
28    fn remove_behaviours_from_relation(&self, relation_instance: ReactiveRelation);
29
30    /// Removes behaviour from the given relation instance's component
31    fn remove_behaviours_from_relation_component(&self, relation_instance: ReactiveRelation, component: Component);
32
33    /// Removes behaviours from the given relation instance by relation instance id.
34    fn remove_behaviours_by_key(&self, relation_instance_id: &RelationInstanceId);
35
36    /// Removes all behaviours of the given behaviour type.
37    fn remove_behaviours_by_behaviour(&self, behaviour_ty: &BehaviourTypeId);
38
39    /// Returns true, if the relation instance has the given behaviour.
40    fn has(&self, relation_instance: ReactiveRelation, behaviour_ty: &BehaviourTypeId) -> bool;
41
42    /// Returns the behaviours of the given relation instance.
43    fn get_all(&self, relation_instance: ReactiveRelation) -> Vec<BehaviourTypeId>;
44
45    /// Returns the relation instances with the given behaviour.
46    fn get_instances_by_behaviour(&self, ty: &BehaviourTypeId) -> Vec<ReactiveRelation>;
47
48    /// Connect
49    fn connect(&self, relation_instance: ReactiveRelation, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
50
51    /// Disconnect
52    fn disconnect(&self, relation_instance: ReactiveRelation, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
53
54    /// Reconnect
55    fn reconnect(&self, relation_instance: ReactiveRelation, behaviour_ty: &BehaviourTypeId) -> Result<(), BehaviourTransitionError>;
56}