Skip to main content

Module subject_sql

Module subject_sql 

Source
Available on crate feature sessions and (crate features postgres or sqlite) only.
Expand description

SQL-backed subject registries and consent stores. SQL-backed SubjectRegistry and ConsentStore implementations.

TableKeyHolds
adk_subjectssubject_key (kind:id)Pseudonym (unique), state, the link, registration time
adk_consent_recordsidOne consent record; indexed by (subject_key, granted_at_us, id)

A subject key is the subject’s kind, a colon, and its id. Kinds contain no colon, so two subjects never share a key.

ChangeStatementWhy it has one winner
ensure, set_stateINSERT ... ON CONFLICT (subject_key) DO NOTHING / DO UPDATEThe primary key admits one insert
linkUPDATE ... WHERE subject_key = $k AND linked_to IS NULL AND state = 'active'The empty link is compared inside the write
grantINSERT ... ON CONFLICT (id) DO NOTHINGThe primary key admits one insert
revokeUPDATE ... WHERE id = $k AND revoked_at_us IS NULLThe first revocation is kept
BackendFeature
SqliteSubjectRegistry, SqliteConsentStoresqlite
PostgresSubjectRegistry, PostgresConsentStorepostgres

Structs§

SqliteConsentStore
SQLite-backed ConsentStore.
SqliteSubjectRegistry
SQLite-backed SubjectRegistry.