pub struct Engine { /* private fields */ }Expand description
The policy evaluation engine.
Loads one or more policies and evaluates incoming actions against them. Rules are evaluated in order; the first matching rule determines the outcome. If no rule matches, the default is to deny (fail-closed).
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn load_policy(&mut self, policy: Policy)
pub fn load_policy(&mut self, policy: Policy)
Loads a policy into the engine.
Sourcepub fn load_policy_yaml(&mut self, yaml: &str) -> Result<(), KvlarError>
pub fn load_policy_yaml(&mut self, yaml: &str) -> Result<(), KvlarError>
Loads a policy from a YAML string.
Sourcepub fn policy_count(&self) -> usize
pub fn policy_count(&self) -> usize
Returns the number of loaded policies.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Returns the total number of rules across all loaded policies.
Sourcepub fn evaluate(&self, action: &Action) -> Decision
pub fn evaluate(&self, action: &Action) -> Decision
Evaluates an action against all loaded policies.
Rules are checked in order across policies (first policy’s rules first).
The first matching rule determines the decision. If no rule matches,
the policy’s default_outcome is used (defaults to deny / fail-closed).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more