pub struct PermissionRuleSet { /* private fields */ }Expand description
An ordered collection of permission rules evaluated highest-priority-first.
Implementations§
Source§impl PermissionRuleSet
impl PermissionRuleSet
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a rule set with built-in security defaults.
Includes auto-deny for reading/writing .env files and other credential files,
while allowing .env.example.
Sourcepub fn add_rule(&mut self, rule: PermissionRule)
pub fn add_rule(&mut self, rule: PermissionRule)
Add a rule to the set.
Sourcepub fn remove_rules<F: Fn(&PermissionRule) -> bool>(&mut self, predicate: F)
pub fn remove_rules<F: Fn(&PermissionRule) -> bool>(&mut self, predicate: F)
Remove all rules matching a predicate.
Sourcepub fn rules(&self) -> &[PermissionRule]
pub fn rules(&self) -> &[PermissionRule]
Read-only access to the rules.
Sourcepub fn evaluate(
&self,
tool_name: &str,
args: &str,
working_dir: Option<&Path>,
) -> Option<PermissionAction>
pub fn evaluate( &self, tool_name: &str, args: &str, working_dir: Option<&Path>, ) -> Option<PermissionAction>
Evaluate a tool invocation against the rule set.
tool_name is the tool being invoked (e.g. "bash", "edit").
args is the argument string (e.g. the command or file path).
working_dir is the optional directory context for directory-scoped rules.
Returns the action from the highest-priority matching rule, or None if
no rule matches.
Sourcepub fn evaluate_simple(
&self,
tool_name: &str,
args: &str,
) -> Option<PermissionAction>
pub fn evaluate_simple( &self, tool_name: &str, args: &str, ) -> Option<PermissionAction>
Convenience wrapper without directory context.
Trait Implementations§
Source§impl Clone for PermissionRuleSet
impl Clone for PermissionRuleSet
Source§fn clone(&self) -> PermissionRuleSet
fn clone(&self) -> PermissionRuleSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PermissionRuleSet
impl Debug for PermissionRuleSet
Source§impl Default for PermissionRuleSet
impl Default for PermissionRuleSet
Source§fn default() -> PermissionRuleSet
fn default() -> PermissionRuleSet
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for PermissionRuleSet
impl<'de> Deserialize<'de> for PermissionRuleSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PermissionRuleSet
impl RefUnwindSafe for PermissionRuleSet
impl Send for PermissionRuleSet
impl Sync for PermissionRuleSet
impl Unpin for PermissionRuleSet
impl UnsafeUnpin for PermissionRuleSet
impl UnwindSafe for PermissionRuleSet
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