pub struct CompositePermissionChecker { /* private fields */ }Expand description
Chains multiple PermissionPolicy implementations into a single PermissionChecker.
Policies are evaluated in registration order. The first Deny short-circuits
immediately. If any policy returns RequireApproval, that is used unless a
later policy denies. If at least one policy returns Allow and none deny or
require approval, the result is Allow. Otherwise the fallback decision
is returned.
§Example
use agentkit_tools_core::{
CommandPolicy, CompositePermissionChecker, PathPolicy, PermissionDecision,
};
let checker = CompositePermissionChecker::new(PermissionDecision::Allow)
.with_policy(PathPolicy::new().allow_root("/workspace"))
.with_policy(CommandPolicy::new().allow_executable("git"));Implementations§
Source§impl CompositePermissionChecker
impl CompositePermissionChecker
Sourcepub fn new(fallback: PermissionDecision) -> Self
pub fn new(fallback: PermissionDecision) -> Self
Creates a new composite checker with the given fallback decision.
The fallback is used when no policy has an opinion about a request.
§Arguments
fallback- Decision returned when every policy returnsPolicyMatch::NoOpinion.
Sourcepub fn with_policy(self, policy: impl PermissionPolicy + 'static) -> Self
pub fn with_policy(self, policy: impl PermissionPolicy + 'static) -> Self
Appends a policy to the evaluation chain and returns self for chaining.
Trait Implementations§
Source§impl PermissionChecker for CompositePermissionChecker
impl PermissionChecker for CompositePermissionChecker
Source§fn evaluate(&self, request: &dyn PermissionRequest) -> PermissionDecision
fn evaluate(&self, request: &dyn PermissionRequest) -> PermissionDecision
Evaluate a single permission request and return the decision.
Auto Trait Implementations§
impl Freeze for CompositePermissionChecker
impl !RefUnwindSafe for CompositePermissionChecker
impl Send for CompositePermissionChecker
impl Sync for CompositePermissionChecker
impl Unpin for CompositePermissionChecker
impl UnsafeUnpin for CompositePermissionChecker
impl !UnwindSafe for CompositePermissionChecker
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