pub struct CapabilityCache {
ttl_secs: i64,
clock: Arc<dyn Clock>,
map: Mutex<HashMap<(ProfileId, Option<BucketId>, String), CapabilityRecord>>,
}Expand description
In-memory capability classification cache.
Thread-safe; meant to be wrapped in Arc and shared across Tauri commands
as a managed CapabilityHandle.
Fields§
§ttl_secs: i64§clock: Arc<dyn Clock>§map: Mutex<HashMap<(ProfileId, Option<BucketId>, String), CapabilityRecord>>Implementations§
Source§impl CapabilityCache
impl CapabilityCache
Sourcepub fn record_capability(
&self,
profile: &ProfileId,
bucket: Option<&BucketId>,
op: &str,
class: CapabilityClass,
)
pub fn record_capability( &self, profile: &ProfileId, bucket: Option<&BucketId>, op: &str, class: CapabilityClass, )
Insert or update a capability record for the given (profile, bucket, op) triple.
bucket is None for profile-level operations (e.g. ListBuckets).
Sourcepub fn record_from_error(
&self,
profile: &ProfileId,
bucket: Option<&BucketId>,
op: &str,
error: &AppError,
) -> Result<bool, AppError>
pub fn record_from_error( &self, profile: &ProfileId, bucket: Option<&BucketId>, op: &str, error: &AppError, ) -> Result<bool, AppError>
Classify error and, if classifiable, record the result for the given
(profile, bucket, op) triple.
Returns Ok(true) when the error was classified and stored.
Returns Ok(false) when the error is not classifiable (no record is
stored).
Sourcepub fn get(
&self,
profile: &ProfileId,
bucket: Option<&BucketId>,
op: &str,
) -> Option<CapabilityRecord>
pub fn get( &self, profile: &ProfileId, bucket: Option<&BucketId>, op: &str, ) -> Option<CapabilityRecord>
Look up a capability record. Returns None if missing or expired.
Sourcepub fn get_map(&self, profile: &ProfileId) -> CapabilityMap
pub fn get_map(&self, profile: &ProfileId) -> CapabilityMap
Return all non-expired capability records for profile as a flat map.
Key format: "<bucket>/<op>" where <bucket> is empty for
profile-level operations.
Sourcepub fn clear(&self, profile: &ProfileId, scope: &ClearScope)
pub fn clear(&self, profile: &ProfileId, scope: &ClearScope)
Remove entries for profile that match scope.
After clear(All) the profile has zero entries in the cache. After
clear(Bucket(id)) only that bucket’s entries are removed (other
buckets and profile-level ops remain). After clear(Op(name)) only
entries with that exact operation string are removed.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CapabilityCache
impl !RefUnwindSafe for CapabilityCache
impl Send for CapabilityCache
impl Sync for CapabilityCache
impl Unpin for CapabilityCache
impl UnsafeUnpin for CapabilityCache
impl !UnwindSafe for CapabilityCache
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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