pub struct PolicyEngine { /* private fields */ }Expand description
Policy evaluation engine.
Rules are evaluated in order; first match wins. When no profile is loaded, all actions are allowed.
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty policy engine (allows everything) with default
ConflictResolutionStrategy::PriorityFirstMatch.
Sourcepub fn with_strategy(strategy: ConflictResolutionStrategy) -> Self
pub fn with_strategy(strategy: ConflictResolutionStrategy) -> Self
Create a policy engine with a specific conflict resolution strategy.
Sourcepub fn strategy(&self) -> ConflictResolutionStrategy
pub fn strategy(&self) -> ConflictResolutionStrategy
Return the active conflict resolution strategy.
Sourcepub fn resolve_conflicts(
&self,
candidates: &[CandidateDecision],
) -> ResolutionResult
pub fn resolve_conflicts( &self, candidates: &[CandidateDecision], ) -> ResolutionResult
Resolve conflicts among multiple candidate decisions using the configured strategy.
Returns a ResolutionResult describing which decision won,
whether a conflict was detected, and how many candidates were
evaluated.
Sourcepub fn load_from_yaml(&self, yaml: &str) -> Result<(), PolicyError>
pub fn load_from_yaml(&self, yaml: &str) -> Result<(), PolicyError>
Load a policy profile from a YAML string.
Sourcepub fn load_from_file(&self, path: &str) -> Result<(), PolicyError>
pub fn load_from_file(&self, path: &str) -> Result<(), PolicyError>
Load a policy profile from a YAML file on disk.
Sourcepub fn evaluate(
&self,
action: &str,
context: Option<&HashMap<String, Value>>,
) -> PolicyDecision
pub fn evaluate( &self, action: &str, context: Option<&HashMap<String, Value>>, ) -> PolicyDecision
Evaluate an action against the loaded policy.
If no profile is loaded, returns PolicyDecision::Allow.
An optional context map is matched against rule conditions.