pub struct Graph { /* private fields */ }Implementations§
Source§impl Graph
impl Graph
pub fn new() -> Self
pub fn is_empty(&self) -> bool
Sourcepub fn set_evaluation_mode(&mut self, use_three_valued_logic: bool)
pub fn set_evaluation_mode(&mut self, use_three_valued_logic: bool)
Set the evaluation mode for policy evaluation.
When use_three_valued_logic is true, policies will use three-valued logic (True, False, NULL).
When false, policies will use strict boolean logic (True, False).
Sourcepub fn use_three_valued_logic(&self) -> bool
pub fn use_three_valued_logic(&self) -> bool
Get the current evaluation mode.
pub fn config(&self) -> &GraphConfig
pub fn config_mut(&mut self) -> &mut GraphConfig
pub fn entity_count(&self) -> usize
pub fn add_entity(&mut self, entity: Entity) -> Result<(), String>
pub fn has_entity(&self, id: &ConceptId) -> bool
pub fn get_entity(&self, id: &ConceptId) -> Option<&Entity>
Sourcepub fn get_entity_mut(&mut self, id: &ConceptId) -> Option<&mut Entity>
pub fn get_entity_mut(&mut self, id: &ConceptId) -> Option<&mut Entity>
Returns a mutable reference to an Entity identified by id.
This method is necessary for operations that need to update attributes
on existing entities (such as association relationships).
pub fn remove_entity(&mut self, id: &ConceptId) -> Result<Entity, String>
pub fn role_count(&self) -> usize
pub fn add_role(&mut self, role: Role) -> Result<(), String>
pub fn get_role(&self, id: &ConceptId) -> Option<&Role>
pub fn has_role(&self, id: &ConceptId) -> bool
pub fn assign_role_to_entity( &mut self, entity_id: ConceptId, role_id: ConceptId, ) -> Result<(), String>
pub fn roles_for_entity(&self, entity_id: &ConceptId) -> Option<&Vec<ConceptId>>
pub fn role_names_for_entity(&self, entity_id: &ConceptId) -> Vec<String>
pub fn resource_count(&self) -> usize
pub fn add_resource(&mut self, resource: Resource) -> Result<(), String>
pub fn has_resource(&self, id: &ConceptId) -> bool
pub fn get_resource(&self, id: &ConceptId) -> Option<&Resource>
pub fn remove_resource(&mut self, id: &ConceptId) -> Result<Resource, String>
pub fn flow_count(&self) -> usize
pub fn pattern_count(&self) -> usize
pub fn relation_count(&self) -> usize
pub fn add_relation_type( &mut self, relation: RelationType, ) -> Result<(), String>
pub fn all_relations(&self) -> Vec<&RelationType>
pub fn add_flow(&mut self, flow: Flow) -> Result<(), String>
pub fn add_pattern(&mut self, pattern: Pattern) -> Result<(), String>
pub fn add_concept_change( &mut self, change: ConceptChange, ) -> Result<(), String>
pub fn get_concept_change(&self, id: &ConceptId) -> Option<&ConceptChange>
pub fn all_concept_changes(&self) -> Vec<&ConceptChange>
pub fn has_flow(&self, id: &ConceptId) -> bool
pub fn get_flow(&self, id: &ConceptId) -> Option<&Flow>
pub fn remove_flow(&mut self, id: &ConceptId) -> Result<Flow, String>
pub fn instance_count(&self) -> usize
pub fn add_instance(&mut self, instance: ResourceInstance) -> Result<(), String>
Sourcepub fn add_association(
&mut self,
owner: &ConceptId,
owned: &ConceptId,
rel_type: &str,
) -> Result<(), String>
pub fn add_association( &mut self, owner: &ConceptId, owned: &ConceptId, rel_type: &str, ) -> Result<(), String>
Adds an association relationship from owner -> owned using a named rel_type.
Associations are represented as a JSON attribute associations on the source entity to
maintain a simple, serializable representation without introducing a new primitive.
pub fn has_instance(&self, id: &ConceptId) -> bool
pub fn get_instance(&self, id: &ConceptId) -> Option<&ResourceInstance>
pub fn remove_instance( &mut self, id: &ConceptId, ) -> Result<ResourceInstance, String>
pub fn entity_instance_count(&self) -> usize
pub fn add_entity_instance(&mut self, instance: Instance) -> Result<(), String>
pub fn get_entity_instance(&self, name: &str) -> Option<&Instance>
pub fn get_entity_instance_mut(&mut self, name: &str) -> Option<&mut Instance>
pub fn all_entity_instances(&self) -> Vec<&Instance>
pub fn remove_entity_instance(&mut self, name: &str) -> Result<Instance, String>
pub fn has_entity_instance_by_id(&self, id: &ConceptId) -> bool
pub fn get_entity_instance_by_id(&self, id: &ConceptId) -> Option<&Instance>
pub fn remove_entity_instance_by_id( &mut self, id: &ConceptId, ) -> Result<Instance, String>
pub fn flows_from(&self, entity_id: &ConceptId) -> Vec<&Flow>
pub fn flows_to(&self, entity_id: &ConceptId) -> Vec<&Flow>
pub fn upstream_entities(&self, entity_id: &ConceptId) -> Vec<&Entity>
pub fn downstream_entities(&self, entity_id: &ConceptId) -> Vec<&Entity>
pub fn find_entity_by_name_and_namespace( &self, name: &str, namespace: &str, ) -> Option<ConceptId>
pub fn find_entity_by_name(&self, name: &str) -> Option<ConceptId>
pub fn find_resource_by_name(&self, name: &str) -> Option<ConceptId>
pub fn find_role_by_name(&self, name: &str) -> Option<ConceptId>
pub fn find_entity_instance_by_name(&self, name: &str) -> Option<ConceptId>
pub fn find_entity_instance_by_name_and_namespace( &self, name: &str, namespace: &str, ) -> Option<ConceptId>
pub fn find_pattern( &self, name: &str, namespace: Option<&str>, ) -> Option<&Pattern>
pub fn all_entities(&self) -> Vec<&Entity>
pub fn all_roles(&self) -> Vec<&Role>
pub fn all_resources(&self) -> Vec<&Resource>
pub fn all_flows(&self) -> Vec<&Flow>
pub fn all_instances(&self) -> Vec<&ResourceInstance>
pub fn all_patterns(&self) -> Vec<&Pattern>
pub fn policy_count(&self) -> usize
pub fn add_policy(&mut self, policy: Policy) -> Result<(), String>
pub fn has_policy(&self, id: &ConceptId) -> bool
pub fn get_policy(&self, id: &ConceptId) -> Option<&Policy>
pub fn remove_policy(&mut self, id: &ConceptId) -> Result<Policy, String>
pub fn all_policies(&self) -> Vec<&Policy>
pub fn metric_count(&self) -> usize
pub fn add_metric(&mut self, metric: Metric) -> Result<(), String>
pub fn has_metric(&self, id: &ConceptId) -> bool
pub fn get_metric(&self, id: &ConceptId) -> Option<&Metric>
pub fn all_metrics(&self) -> Vec<&Metric>
pub fn mapping_count(&self) -> usize
pub fn add_mapping(&mut self, mapping: MappingContract) -> Result<(), String>
pub fn has_mapping(&self, id: &ConceptId) -> bool
pub fn get_mapping(&self, id: &ConceptId) -> Option<&MappingContract>
pub fn all_mappings(&self) -> Vec<&MappingContract>
pub fn projection_count(&self) -> usize
pub fn add_projection( &mut self, projection: ProjectionContract, ) -> Result<(), String>
pub fn has_projection(&self, id: &ConceptId) -> bool
pub fn get_projection(&self, id: &ConceptId) -> Option<&ProjectionContract>
pub fn all_projections(&self) -> Vec<&ProjectionContract>
Sourcepub fn extend(&mut self, other: Graph) -> Result<(), String>
pub fn extend(&mut self, other: Graph) -> Result<(), String>
Extend this graph with all nodes and policies from another graph. The operation is atomic: the existing graph is only modified if the entire merge succeeds, which prevents partial state when errors occur.
Sourcepub fn validate(&self) -> ValidationResult
pub fn validate(&self) -> ValidationResult
Validate the graph by evaluating all policies against it and
collecting any violations produced. Returns a ValidationResult.