pub struct Policy { /* private fields */ }Expand description
Execution policy containing rules for command authorization.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn add_prefix_rule(
&mut self,
pattern: &[String],
decision: Decision,
) -> Result<()>
pub fn add_prefix_rule( &mut self, pattern: &[String], decision: Decision, ) -> Result<()>
Add a prefix rule to the policy.
Sourcepub fn rules(&self) -> &[PrefixRule]
pub fn rules(&self) -> &[PrefixRule]
The prefix rules in evaluation order (first match wins).
Sourcepub fn prepend_layer(&mut self, rules: impl IntoIterator<Item = PrefixRule>)
pub fn prepend_layer(&mut self, rules: impl IntoIterator<Item = PrefixRule>)
Prepend a higher-precedence layer of rules.
Used when merging rule-file layers (workspace rules over user rules):
a pattern that already exists — either in this policy or earlier within
rules — keeps its first occurrence, so the highest-precedence layer
wins and evaluation order (check) stays deterministic.
Sourcepub fn check(&self, command: &[String]) -> RuleMatch
pub fn check(&self, command: &[String]) -> RuleMatch
Check a single command against the policy.
Sourcepub fn check_multiple<'a, I, F>(
&self,
commands: I,
heuristics_fallback: &F,
) -> PolicyEvaluation
pub fn check_multiple<'a, I, F>( &self, commands: I, heuristics_fallback: &F, ) -> PolicyEvaluation
Check multiple commands against the policy.
Sourcepub fn prefix_rules(&self) -> &[PrefixRule]
pub fn prefix_rules(&self) -> &[PrefixRule]
Get all prefix rules.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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