pub struct CacheKey(pub [u8; 32]);Expand description
Cache key derived from a request (and the current policy version).
Tuple Fields§
§0: [u8; 32]Implementations§
Source§impl CacheKey
impl CacheKey
Sourcepub fn for_request(req: &AgentRequest, policy_version: u64) -> Self
pub fn for_request(req: &AgentRequest, policy_version: u64) -> Self
Derive a key from an agent request without additional entities.
Includes policy_version so a policy reload invalidates all entries.
Streams each field’s canonical JSON through the hasher, avoiding the
intermediate String allocations the previous implementation made.
For high-throughput PDPs (thousands of decisions/sec) this matters.
§Examples
use agentguard_core::{AgentRequestBuilder, Principal, AgentAction, Resource, AgentContext};
use agentguard_core::decision::cache::CacheKey;
let req = AgentRequestBuilder::new(Principal::user("alice"))
.action(AgentAction::tool("send_email"))
.resource(Resource::new("Mailbox", "alice@acme"))
.context(AgentContext::new())
.build()
.unwrap();
let _k = CacheKey::for_request(&req, 0);Sourcepub fn for_request_with_entities(
req: &AgentRequest,
entities: &Entities,
policy_version: u64,
) -> Self
pub fn for_request_with_entities( req: &AgentRequest, entities: &Entities, policy_version: u64, ) -> Self
Derive a key from an agent request and the complete Cedar entity set. Entity attributes and parent relationships can change a decision even when the visible request is identical, so they are part of the cache identity and are canonicalized in deterministic order.
pub fn as_hex(&self) -> String
Trait Implementations§
impl Eq for CacheKey
impl StructuralPartialEq for CacheKey
Auto Trait Implementations§
impl Freeze for CacheKey
impl RefUnwindSafe for CacheKey
impl Send for CacheKey
impl Sync for CacheKey
impl Unpin for CacheKey
impl UnwindSafe for CacheKey
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§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>
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