pub struct DurableInviteStore { /* private fields */ }Expand description
Storage-backed invite state. Every mutating operation is one conditional KV batch, so two daemons cannot consume the same token even if an outer process lock is lost.
Implementations§
Source§impl DurableInviteStore
impl DurableInviteStore
Sourcepub async fn redeemable(
&self,
token_hash: &str,
) -> StorageResult<Option<Invite>>
pub async fn redeemable( &self, token_hash: &str, ) -> StorageResult<Option<Invite>>
Read one currently redeemable invite without consuming it.
Handlers use this to prepare fallible provisioning before the atomic
consume that commits a redemption. Callers must commit with
Self::consume_if_unchanged so a stale provisioned identity cannot
win after another daemon consumed the same record.
§Errors
Returns a storage error if the record cannot be read or decoded.
Sourcepub async fn consume_if_unchanged(
&self,
expected: &Invite,
) -> StorageResult<bool>
pub async fn consume_if_unchanged( &self, expected: &Invite, ) -> StorageResult<bool>
Consume the exact invite previously returned by Self::redeemable.
This is the commit operation for prepare-then-consume handlers. It fails closed if the record changed, expired, or was consumed while the caller performed provisioning.
§Errors
Returns a storage error if the conditional mutation cannot be applied.
Sourcepub async fn consume_with_ownership(
&self,
expected: &Invite,
ownership: &OwnershipStore,
principal: PrincipalUid,
) -> Result<bool, OwnershipError>
pub async fn consume_with_ownership( &self, expected: &Invite, ownership: &OwnershipStore, principal: PrincipalUid, ) -> Result<bool, OwnershipError>
Commit token consumption and principal ownership in one backend batch. The ownership store must use the same authoritative runtime KV backend.
§Errors
Returns validation or potentially ambiguous storage errors; only a definite false permits rollback of the new identity.
Source§impl DurableInviteStore
impl DurableInviteStore
Sourcepub fn new(backend: Arc<dyn KvStore>) -> StorageResult<Self>
pub fn new(backend: Arc<dyn KvStore>) -> StorageResult<Self>
Bind the fixed system-control projection.
§Errors
Returns a storage error if the backend rejects the fixed invite namespace.
Sourcepub async fn ensure_legacy_import(&self, home: &AstridHome) -> StorageResult<()>
pub async fn ensure_legacy_import(&self, home: &AstridHome) -> StorageResult<()>
Ensure a released native invite file has been imported exactly once. The source is validated and parsed before any durable mutation. A durable receipt makes restart idempotent; retirement happens only after record and receipt read-back succeeds.
§Errors
Returns a storage error if the legacy source is unsafe or malformed, conflicts with durable state, or cannot be durably imported.
Sourcepub async fn list(&self) -> StorageResult<Vec<Invite>>
pub async fn list(&self) -> StorageResult<Vec<Invite>>
Load all current records in deterministic token-identifier order.
§Errors
Returns a storage error if records cannot be listed or decoded.
Sourcepub async fn issue(&self, invite: &Invite) -> StorageResult<bool>
pub async fn issue(&self, invite: &Invite) -> StorageResult<bool>
Insert one invite iff its identifier is absent.
§Errors
Returns a storage error if the conditional batch cannot be applied.
Sourcepub async fn redeem(&self, token_hash: &str) -> StorageResult<Option<Invite>>
pub async fn redeem(&self, token_hash: &str) -> StorageResult<Option<Invite>>
Atomically consume one invite. Only one concurrent caller can win.
§Errors
Returns a storage error if the record cannot be read, decoded, or conditionally removed.
Sourcepub async fn revoke(&self, token_hash: &str) -> StorageResult<bool>
pub async fn revoke(&self, token_hash: &str) -> StorageResult<bool>
Remove one invite by its canonical fingerprint.
§Errors
Returns a storage error if the conditional delete cannot be applied.
Sourcepub async fn prune(&self) -> StorageResult<usize>
pub async fn prune(&self) -> StorageResult<usize>
Prune expired and exhausted records using conditional deletes.
§Errors
Returns a storage error if records cannot be read or a conditional delete cannot be applied.
Trait Implementations§
Source§impl Clone for DurableInviteStore
impl Clone for DurableInviteStore
Source§fn clone(&self) -> DurableInviteStore
fn clone(&self) -> DurableInviteStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for DurableInviteStore
impl !UnwindSafe for DurableInviteStore
impl Freeze for DurableInviteStore
impl Send for DurableInviteStore
impl Sync for DurableInviteStore
impl Unpin for DurableInviteStore
impl UnsafeUnpin for DurableInviteStore
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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