pub struct Graph { /* private fields */ }Implementations§
Source§impl Graph
impl Graph
pub fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn add_declared_dimension(&mut self, name: String, namespace: String)
pub fn add_declared_unit( &mut self, name: String, namespace: String, dimension: String, base_factor: String, base_unit: String, )
pub fn all_declared_dimensions(&self) -> Vec<&DeclaredDimension>
pub fn all_declared_units(&self) -> Vec<&DeclaredUnit>
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
Sourcepub fn version(&self) -> Option<&str>
pub fn version(&self) -> Option<&str>
The model’s declared @version, if the source header declares one.
pub fn config_mut(&mut self) -> &mut GraphConfig
pub fn entity_count(&self) -> usize
Sourcepub fn is_operation_bound_policy(&self, id: &ConceptId) -> bool
pub fn is_operation_bound_policy(&self, id: &ConceptId) -> bool
Whether id is bound to an operation’s access policy_governed by
clause (and so is skipped by validate()).
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>
Sourcepub fn add_entity_instances(
&mut self,
instances: Vec<Instance>,
) -> Result<(), String>
pub fn add_entity_instances( &mut self, instances: Vec<Instance>, ) -> Result<(), String>
Insert several entity instances and validate the graph once, after all
of them are present, so references between the new instances do not
depend on their order. If any insert or the final validation fails,
every instance inserted by this call is removed and the graph is
unchanged. Duplicate ids and names are rejected as in
Graph::add_entity_instance, including duplicates inside the batch.
pub fn entity_contract(&self, entity_id: &ConceptId) -> Option<&EntityContract>
pub fn validate_entity_instances(&self) -> Result<(), Vec<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.