Skip to main content

FormTokenStore

Trait FormTokenStore 

Source
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§

Source

fn insert_form_token( &self, record: FormTokenRecord, ) -> impl Future<Output = Result<(), StoreError>>

Insert a new form token record.

Source

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:

  1. Run the conditional UPDATE (sets consumed_at).
  2. If changed == 0, run a follow-up SELECT to classify why.
  3. Call crate::state::classify_token_consume with the results.
  4. Return the outcome plus any stored result_ref for replays.
Source

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".

Implementors§