reactive_graph_plugin_api/instances/entities/
entity_instance_manager.rs1use std::collections::HashMap;
2
3use uuid::Uuid;
4
5use reactive_graph_behaviour_model_api::BehaviourTypeId;
6use reactive_graph_graph::ComponentTypeId;
7use reactive_graph_graph::EntityInstance;
8use reactive_graph_graph::EntityTypeId;
9use reactive_graph_reactive_model_impl::ReactiveEntity;
10use reactive_graph_reactive_service_api::ReactiveEntityComponentAddError;
11use reactive_graph_reactive_service_api::ReactiveEntityCreationError;
12use reactive_graph_reactive_service_api::ReactiveEntityRegistrationError;
13
14pub trait EntityInstanceManager: Send + Sync {
15 fn has(&self, id: Uuid) -> bool;
17
18 fn get(&self, id: Uuid) -> Option<ReactiveEntity>;
20
21 fn get_by_label(&self, label: &str) -> Option<ReactiveEntity>;
23
24 fn get_by_label_with_params(&self, label: &str) -> Option<(ReactiveEntity, HashMap<String, String>)>;
28
29 fn get_all(&self) -> Vec<ReactiveEntity>;
31
32 fn get_by_type(&self, ty: &EntityTypeId) -> Vec<ReactiveEntity>;
34
35 fn get_ids(&self) -> Vec<Uuid>;
37
38 fn count(&self) -> usize;
40
41 fn count_by_type(&self, ty: &EntityTypeId) -> usize;
43
44 fn count_by_component(&self, component: &ComponentTypeId) -> usize;
46
47 fn count_by_behaviour(&self, behaviour_ty: &BehaviourTypeId) -> usize;
49
50 fn create(&self, entity_instance: EntityInstance) -> Result<ReactiveEntity, ReactiveEntityCreationError>;
52
53 fn register(&self, reactive_entity: ReactiveEntity) -> Result<ReactiveEntity, ReactiveEntityRegistrationError>;
55
56 fn add_component(&self, id: Uuid, component: &ComponentTypeId) -> Result<(), ReactiveEntityComponentAddError>;
58
59 fn remove_component(&self, id: Uuid, component: &ComponentTypeId);
61
62 fn delete(&self, id: Uuid) -> bool;
64}