pub struct SqliteStore { /* private fields */ }Expand description
A handle wrapping a sqlx::SqlitePool that implements all codlet
store traits (RFC-011).
Clone is cheap (the pool is reference-counted internally).
Requires the sqlite Cargo feature (enabled by default).
Implementations§
Source§impl SqliteStore
impl SqliteStore
Sourcepub fn new(pool: SqlitePool) -> Self
pub fn new(pool: SqlitePool) -> Self
Construct from an existing pool.
Call run_migrations on the pool before any store operations.
Sourcepub fn pool(&self) -> &SqlitePool
pub fn pool(&self) -> &SqlitePool
Borrow the underlying pool.
Trait Implementations§
Source§impl Clone for SqliteStore
impl Clone for SqliteStore
Source§fn clone(&self) -> SqliteStore
fn clone(&self) -> SqliteStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl CodeAdminStore for SqliteStore
impl CodeAdminStore for SqliteStore
Source§async fn list_codes(
&self,
filter: &CodeListFilter,
now: u64,
) -> Result<Vec<CodeMeta>, StoreError>
async fn list_codes( &self, filter: &CodeListFilter, now: u64, ) -> Result<Vec<CodeMeta>, StoreError>
Source§async fn get_code_meta(
&self,
code_id: &CodeId,
) -> Result<Option<CodeMeta>, StoreError>
async fn get_code_meta( &self, code_id: &CodeId, ) -> Result<Option<CodeMeta>, StoreError>
Retrieve a single code’s metadata by its record ID. Read more
Source§impl CodeStore for SqliteStore
impl CodeStore for SqliteStore
Source§async fn find_redeemable(
&self,
candidates: &[LookupKey],
now: u64,
scope: Option<&str>,
) -> Result<Option<RedeemableCode>, StoreError>
async fn find_redeemable( &self, candidates: &[LookupKey], now: u64, scope: Option<&str>, ) -> Result<Option<RedeemableCode>, StoreError>
Look up a redeemable code by its HMAC lookup key candidates. Read more
Source§async fn claim_code(
&self,
req: &ClaimRequest<'_>,
) -> Result<ClaimOutcome, StoreError>
async fn claim_code( &self, req: &ClaimRequest<'_>, ) -> Result<ClaimOutcome, StoreError>
Attempt to atomically claim a code record. Read more
Source§async fn insert_code(&self, record: CodeRecord) -> Result<(), StoreError>
async fn insert_code(&self, record: CodeRecord) -> Result<(), StoreError>
Insert a new code record. Returns
StoreError if the lookup key
already exists (unique constraint violation on the HMAC column).Source§async fn revoke_code(
&self,
code_id: &CodeId,
scope: Option<&str>,
now: u64,
) -> Result<(), StoreError>
async fn revoke_code( &self, code_id: &CodeId, scope: Option<&str>, now: u64, ) -> Result<(), StoreError>
Revoke a code by its record ID, scoped to
scope when provided.
Only affects records that are not yet used or revoked.Source§impl Debug for SqliteStore
impl Debug for SqliteStore
Source§impl FormTokenStore for SqliteStore
impl FormTokenStore for SqliteStore
Source§async fn insert_form_token(
&self,
record: FormTokenRecord,
) -> Result<(), StoreError>
async fn insert_form_token( &self, record: FormTokenRecord, ) -> Result<(), StoreError>
Insert a new form token record.
Source§async fn consume_form_token(
&self,
lookup_key: &LookupKey,
subject: &TokenSubject,
purpose: &str,
bound_resource: Option<&str>,
now: u64,
) -> Result<(TokenConsumeOutcome, Option<String>), StoreError>
async fn consume_form_token( &self, lookup_key: &LookupKey, subject: &TokenSubject, purpose: &str, bound_resource: Option<&str>, now: u64, ) -> Result<(TokenConsumeOutcome, Option<String>), StoreError>
Attempt to atomically consume a form token. Read more
Source§async fn set_token_result(
&self,
lookup_key: &LookupKey,
result_ref: &str,
) -> Result<(), StoreError>
async fn set_token_result( &self, lookup_key: &LookupKey, result_ref: &str, ) -> Result<(), StoreError>
Store a result reference on a consumed token for idempotency replay.
Source§impl SessionStore for SqliteStore
impl SessionStore for SqliteStore
Source§async fn find_active_session(
&self,
candidates: &[LookupKey],
now: u64,
) -> Result<Option<ActiveSessionRecord>, StoreError>
async fn find_active_session( &self, candidates: &[LookupKey], now: u64, ) -> Result<Option<ActiveSessionRecord>, StoreError>
Look up an active session by HMAC lookup key candidates. Read more
Source§async fn insert_session(&self, record: SessionRecord) -> Result<(), StoreError>
async fn insert_session(&self, record: SessionRecord) -> Result<(), StoreError>
Insert a new session record.
Source§async fn revoke_session(
&self,
session_id: &SessionId,
now: u64,
) -> Result<(), StoreError>
async fn revoke_session( &self, session_id: &SessionId, now: u64, ) -> Result<(), StoreError>
Revoke a session by its record ID (logout / incident response).
Revocation is monotonic: a revoked session cannot be unrevoked.
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteStore
impl !UnwindSafe for SqliteStore
impl Freeze for SqliteStore
impl Send for SqliteStore
impl Sync for SqliteStore
impl Unpin for SqliteStore
impl UnsafeUnpin for SqliteStore
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,
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