pub struct PermissionCache<K: Eq + Hash> { /* private fields */ }Expand description
Generic permission cache that works for any hashable key type. Eliminates duplication between file-based and tool-based caches.
Implementations§
Source§impl<K: Eq + Hash> PermissionCache<K>
impl<K: Eq + Hash> PermissionCache<K>
Sourcepub fn get_permission<Q>(&mut self, key: &Q) -> Option<PermissionGrant>
pub fn get_permission<Q>(&mut self, key: &Q) -> Option<PermissionGrant>
Check if we have a cached permission for this key
Sourcepub fn cache_grant(&mut self, key: K, grant: PermissionGrant)
pub fn cache_grant(&mut self, key: K, grant: PermissionGrant)
Cache a permission grant
Sourcepub fn invalidate<Q>(&mut self, key: &Q)
pub fn invalidate<Q>(&mut self, key: &Q)
Invalidate permission for a key
Sourcepub fn clear_temporary_denials(&mut self)
pub fn clear_temporary_denials(&mut self)
Clear only temporary denials (for retries)
Sourcepub fn stats(&self) -> PermissionCacheStats
pub fn stats(&self) -> PermissionCacheStats
Get cache statistics
Sourcepub fn is_denied<Q>(&self, key: &Q) -> bool
pub fn is_denied<Q>(&self, key: &Q) -> bool
Check if key is denied by policy (not execution failure)
Sourcepub fn is_temporarily_denied<Q>(&self, key: &Q) -> bool
pub fn is_temporarily_denied<Q>(&self, key: &Q) -> bool
Check if key has a temporary denial (execution failure, not policy)
Sourcepub fn can_use_cached<Q>(&self, key: &Q) -> bool
pub fn can_use_cached<Q>(&self, key: &Q) -> bool
Check if we can use cached permission without prompting.
Once grants are included so that a single user approval persists
for the duration of the session — without this, every identical tool
call would re-prompt even after the user already said “yes”.
Source§impl PermissionCache<String>
Extension methods for ToolPermissionCache to maintain API compatibility
impl PermissionCache<String>
Extension methods for ToolPermissionCache to maintain API compatibility
Sourcepub fn cache_grant_tool(
&mut self,
tool_name: impl Into<String>,
grant: PermissionGrant,
)
pub fn cache_grant_tool( &mut self, tool_name: impl Into<String>, grant: PermissionGrant, )
Cache a permission grant for a tool (accepts impl Into<String>)
Trait Implementations§
Auto Trait Implementations§
impl<K> Forget for PermissionCache<K>
impl<K> Freeze for PermissionCache<K>
impl<K> Move for PermissionCache<K>
impl<K> RefUnwindSafe for PermissionCache<K>
impl<K> Send for PermissionCache<K>
impl<K> Sync for PermissionCache<K>
impl<K> Unpin for PermissionCache<K>
impl<K> UnsafeUnpin for PermissionCache<K>
impl<K> UnwindSafe for PermissionCache<K>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> 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> ⓘ
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> ⓘ
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