pub trait FormTokenStore {
// Required methods
fn insert_form_token(
&self,
record: FormTokenRecord,
) -> impl Future<Output = Result<(), StoreError>>;
fn consume_form_token(
&self,
lookup_key: &LookupKey,
subject: &TokenSubject,
purpose: &str,
bound_resource: Option<&str>,
now: u64,
) -> impl Future<Output = Result<(TokenConsumeOutcome, Option<String>), StoreError>>;
fn set_token_result(
&self,
lookup_key: &LookupKey,
result_ref: &str,
) -> impl Future<Output = Result<(), StoreError>>;
}Expand description
Form-token storage (RFC-007).
The consume operation must be atomic: a conditional UPDATE sets consumed_at
only when the token is unconsumed, unexpired, and bindings match. The
affected-row count drives TokenConsumeOutcome via
crate::state::classify_token_consume.
Required Methods§
Sourcefn insert_form_token(
&self,
record: FormTokenRecord,
) -> impl Future<Output = Result<(), StoreError>>
fn insert_form_token( &self, record: FormTokenRecord, ) -> impl Future<Output = Result<(), StoreError>>
Insert a new form token record.
Sourcefn consume_form_token(
&self,
lookup_key: &LookupKey,
subject: &TokenSubject,
purpose: &str,
bound_resource: Option<&str>,
now: u64,
) -> impl Future<Output = Result<(TokenConsumeOutcome, Option<String>), StoreError>>
fn consume_form_token( &self, lookup_key: &LookupKey, subject: &TokenSubject, purpose: &str, bound_resource: Option<&str>, now: u64, ) -> impl Future<Output = Result<(TokenConsumeOutcome, Option<String>), StoreError>>
Attempt to atomically consume a form token.
The adapter must:
- Run the conditional UPDATE (sets
consumed_at). - If
changed == 0, run a follow-up SELECT to classify why. - Call
crate::state::classify_token_consumewith the results. - Return the outcome plus any stored
result_reffor replays.
Sourcefn set_token_result(
&self,
lookup_key: &LookupKey,
result_ref: &str,
) -> impl Future<Output = Result<(), StoreError>>
fn set_token_result( &self, lookup_key: &LookupKey, result_ref: &str, ) -> impl Future<Output = Result<(), StoreError>>
Store a result reference on a consumed token for idempotency replay.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".