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 (the opposite of Phase 3.5’s durability contract; SQLite
is the production path).
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<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