pub struct InMemoryApprovalStore { /* private fields */ }Expand description
Thread-safe in-memory ApprovalStore. Useful for tests and for
ephemeral deployments where operators explicitly accept data loss
on restart (ephemeral: data is lost on restart; use the SQLite-backed
store for production durability).
Implementations§
Trait Implementations§
Source§impl ApprovalStore for InMemoryApprovalStore
impl ApprovalStore for InMemoryApprovalStore
Source§fn store_pending(
&self,
request: &ApprovalRequest,
) -> Result<(), ApprovalStoreError>
fn store_pending( &self, request: &ApprovalRequest, ) -> Result<(), ApprovalStoreError>
Persist a new pending request. Idempotent on
approval_id: a
second call with the same id returns without error as long as
the stored payload matches.Source§fn get_pending(
&self,
id: &str,
) -> Result<Option<ApprovalRequest>, ApprovalStoreError>
fn get_pending( &self, id: &str, ) -> Result<Option<ApprovalRequest>, ApprovalStoreError>
Fetch a single pending approval by id.
Source§fn list_pending(
&self,
filter: &ApprovalFilter,
) -> Result<Vec<ApprovalRequest>, ApprovalStoreError>
fn list_pending( &self, filter: &ApprovalFilter, ) -> Result<Vec<ApprovalRequest>, ApprovalStoreError>
List all pending approvals matching the filter.
Source§fn resolve(
&self,
id: &str,
decision: &ApprovalDecision,
) -> Result<(), ApprovalStoreError>
fn resolve( &self, id: &str, decision: &ApprovalDecision, ) -> Result<(), ApprovalStoreError>
Mark a pending approval as resolved. Returns
ApprovalStoreError::AlreadyResolved if the request has already
been resolved (double-resolve protection) and
ApprovalStoreError::Replay if the bound token has already been
consumed on a different request.Source§fn count_approved(
&self,
subject_id: &str,
policy_id: &str,
) -> Result<u64, ApprovalStoreError>
fn count_approved( &self, subject_id: &str, policy_id: &str, ) -> Result<u64, ApprovalStoreError>
Count approved calls for a given subject / grant pair. Used by
Constraint::RequireApprovalAbove threshold accounting.Source§fn record_consumed(
&self,
token_id: &str,
parameter_hash: &str,
now: u64,
) -> Result<(), ApprovalStoreError>
fn record_consumed( &self, token_id: &str, parameter_hash: &str, now: u64, ) -> Result<(), ApprovalStoreError>
Record that a token (by
token_id and parameter_hash) has
been consumed. Used to reject replays of the same approval
token across a restart. Implementations may also call this from
[resolve]; exposing it on the trait lets the kernel do the
replay check before persisting the resolution, which matters
when the store is backed by SQLite and wants to run the check
inside the transaction.Source§fn is_consumed(
&self,
token_id: &str,
parameter_hash: &str,
) -> Result<bool, ApprovalStoreError>
fn is_consumed( &self, token_id: &str, parameter_hash: &str, ) -> Result<bool, ApprovalStoreError>
Returns
true if the token has already been consumed.Source§fn get_resolution(
&self,
id: &str,
) -> Result<Option<ResolvedApproval>, ApprovalStoreError>
fn get_resolution( &self, id: &str, ) -> Result<Option<ResolvedApproval>, ApprovalStoreError>
Fetch the resolution record for a previously resolved approval.
Source§impl Default for InMemoryApprovalStore
impl Default for InMemoryApprovalStore
Source§fn default() -> InMemoryApprovalStore
fn default() -> InMemoryApprovalStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for InMemoryApprovalStore
impl RefUnwindSafe for InMemoryApprovalStore
impl Send for InMemoryApprovalStore
impl Sync for InMemoryApprovalStore
impl Unpin for InMemoryApprovalStore
impl UnsafeUnpin for InMemoryApprovalStore
impl UnwindSafe for InMemoryApprovalStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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>
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