pub struct SqliteApprovalStore { /* private fields */ }Expand description
SQLite-backed ApprovalStore.
Schema is created on open. Migrations are additive and idempotent
via CREATE TABLE IF NOT EXISTS.
Implementations§
Source§impl SqliteApprovalStore
impl SqliteApprovalStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, ApprovalStoreError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, ApprovalStoreError>
Open the store at the given path. Creates the parent directory if needed.
Sourcepub fn open_in_memory() -> Result<Self, ApprovalStoreError>
pub fn open_in_memory() -> Result<Self, ApprovalStoreError>
Open an in-memory store for tests.
Trait Implementations§
Source§impl ApprovalStore for SqliteApprovalStore
impl ApprovalStore for SqliteApprovalStore
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.
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteApprovalStore
impl !UnwindSafe for SqliteApprovalStore
impl Freeze for SqliteApprovalStore
impl Send for SqliteApprovalStore
impl Sync for SqliteApprovalStore
impl Unpin for SqliteApprovalStore
impl UnsafeUnpin for SqliteApprovalStore
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