pub struct ScopePolicy {
pub default_deny: bool,
/* private fields */
}Expand description
Per-agent scope policy: the set of scopes that an agent has been granted.
An empty granted set combined with default_deny = true means the agent
cannot execute any tool that requires a scope. With default_deny = false
(the default) all tools are allowed unless they declare required scopes.
Fields§
§default_deny: boolWhen true, a tool with no required scopes is still blocked unless
the policy explicitly grants a wildcard "*". Defaults to false
(no restriction on scope-free tools).
Implementations§
Source§impl ScopePolicy
impl ScopePolicy
Sourcepub fn with_scopes(
self,
scopes: impl IntoIterator<Item = impl Into<Scope>>,
) -> Self
pub fn with_scopes( self, scopes: impl IntoIterator<Item = impl Into<Scope>>, ) -> Self
Replace the granted set.
Sourcepub fn with_default_deny(self, value: bool) -> Self
pub fn with_default_deny(self, value: bool) -> Self
Set default_deny.
Sourcepub fn is_scope_granted(&self, required: &str) -> bool
pub fn is_scope_granted(&self, required: &str) -> bool
Check whether a single required scope is satisfied by this policy.
Matching rules (first match wins):
- Exact match:
"fs:read"satisfies"fs:read". - Namespace wildcard:
"fs:*"satisfies"fs:read","fs:write", etc. - Global wildcard:
"*"satisfies any scope.
Sourcepub fn missing_scopes<'a>(&self, required: &'a [String]) -> Vec<&'a str>
pub fn missing_scopes<'a>(&self, required: &'a [String]) -> Vec<&'a str>
Return the list of required scopes that are NOT granted.
Trait Implementations§
Source§impl Clone for ScopePolicy
impl Clone for ScopePolicy
Source§fn clone(&self) -> ScopePolicy
fn clone(&self) -> ScopePolicy
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 ScopePolicy
impl Debug for ScopePolicy
Auto Trait Implementations§
impl Freeze for ScopePolicy
impl RefUnwindSafe for ScopePolicy
impl Send for ScopePolicy
impl Sync for ScopePolicy
impl Unpin for ScopePolicy
impl UnsafeUnpin for ScopePolicy
impl UnwindSafe for ScopePolicy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more