pub enum CaveatPredicate {
TimeBefore(u64),
TimeAfter(u64),
RegionScope(u64),
TaskScope(u64),
MaxUses(u32),
ResourceScope(String),
RateLimit {
max_count: u32,
window_secs: u32,
},
Custom(String, String),
}Expand description
A predicate that restricts when/where a capability token is valid.
Caveats form a conjunction: all must be satisfied for the token to be valid. New caveats can only narrow (never widen) access.
Variants§
TimeBefore(u64)
Token is valid only before this virtual timestamp (milliseconds).
TimeAfter(u64)
Token is valid only after this virtual timestamp (milliseconds).
RegionScope(u64)
Token is scoped to a specific region ID.
TaskScope(u64)
Token is scoped to a specific task ID.
MaxUses(u32)
Maximum number of times the token may be checked.
ResourceScope(String)
Token is scoped to resources matching a glob pattern.
The pattern uses simple glob syntax: * matches any segment,
** matches any number of segments, exact segments match literally.
RateLimit
Windowed rate limit: at most max_count uses per window_secs seconds.
Checked against VerificationContext::window_use_count. The caller
is responsible for tracking the sliding window externally.
Fields
Custom(String, String)
Custom key-value predicate for extensibility.
Implementations§
Source§impl CaveatPredicate
impl CaveatPredicate
Sourcepub fn from_bytes(data: &[u8]) -> Option<(Self, usize)>
pub fn from_bytes(data: &[u8]) -> Option<(Self, usize)>
Decode a predicate from bytes. Returns the predicate and bytes consumed.
§Errors
Returns None if the bytes are malformed.
Sourcepub fn display_string(&self) -> String
pub fn display_string(&self) -> String
Human-readable summary of this predicate.
Trait Implementations§
Source§impl Clone for CaveatPredicate
impl Clone for CaveatPredicate
Source§fn clone(&self) -> CaveatPredicate
fn clone(&self) -> CaveatPredicate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more