pub struct ScopeGuard { /* private fields */ }Expand description
Declarative scope enforcement for tools.
Wraps tools and automatically checks that the user has all scopes
declared by Tool::required_scopes() before allowing execution.
§Example
ⓘ
use adk_auth::{ScopeGuard, ContextScopeResolver};
let guard = ScopeGuard::new(ContextScopeResolver);
// Wrap a single tool
let protected = guard.protect(my_tool);
// Wrap all tools in a vec
let protected_tools = guard.protect_all(tools);Implementations§
Source§impl ScopeGuard
impl ScopeGuard
Sourcepub fn new(resolver: impl ScopeResolver + 'static) -> Self
pub fn new(resolver: impl ScopeResolver + 'static) -> Self
Create a scope guard with the given resolver.
Sourcepub fn with_audit(
resolver: impl ScopeResolver + 'static,
audit_sink: impl AuditSink + 'static,
) -> Self
pub fn with_audit( resolver: impl ScopeResolver + 'static, audit_sink: impl AuditSink + 'static, ) -> Self
Create a scope guard with audit logging.
Sourcepub fn protect<T: Tool + 'static>(&self, tool: T) -> ScopedTool<T>
pub fn protect<T: Tool + 'static>(&self, tool: T) -> ScopedTool<T>
Wrap a tool with scope enforcement.
If the tool declares no required scopes, the wrapper is a no-op passthrough.
Auto Trait Implementations§
impl Freeze for ScopeGuard
impl !RefUnwindSafe for ScopeGuard
impl Send for ScopeGuard
impl Sync for ScopeGuard
impl Unpin for ScopeGuard
impl UnsafeUnpin for ScopeGuard
impl !UnwindSafe for ScopeGuard
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