pub struct MemoryOwnershipStore(/* private fields */);Expand description
In-process ownership table — tests and single-process deployments. Clones share one table. Each write takes one lock, so the row change and the version advance are atomic as the trait requires.
Implementations§
Trait Implementations§
Source§impl Clone for MemoryOwnershipStore
impl Clone for MemoryOwnershipStore
Source§impl Debug for MemoryOwnershipStore
impl Debug for MemoryOwnershipStore
Source§impl Default for MemoryOwnershipStore
impl Default for MemoryOwnershipStore
Source§impl OwnershipStore for MemoryOwnershipStore
impl OwnershipStore for MemoryOwnershipStore
Source§fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
o: &'life1 NewOwnership,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<Inserted, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn insert<'life0, 'life1, 'async_trait>(
&'life0 self,
o: &'life1 NewOwnership,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<Inserted, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Insert a fresh row and advance the ownership version, atomically. The
impl mints
id and sets granted_at = now; the returned row carries
both, revoked_at is None, and Inserted::version is the version
this insert produced.Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up a row by id.
None if no such row exists (live or revoked).Source§fn revoke_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Soft-delete by id — sets
revoked_at = now if the row is live and
advances the ownership version in the same transaction. Returns the
version after the call: the one this revoke produced, or, when the row
was already revoked (a no-op that changes nothing and advances
nothing), the current one. Returns StoreError::NotFound when the id
is unknown.Source§fn revoke_by_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn revoke_by_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cascading revoke — sweep
revoked_at = now across every live row
held by principal (principal_id = principal), advancing the
ownership version in the same transaction when it sweeps any. Returns
the version after the call: the one the sweep produced, or, when
nothing was live, the current one. Rows the principal merely granted
(granted_by) or was attributed on (on_behalf_of) are untouched, by
design (D4). A deletion cascade goes through
revoke_principal_ownership, which
also tells offline edges.Source§fn list_history_for_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_history_for_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Every row held by
principal directly — subject
Subject::Principal — live or revoked, in unspecified order.
What a principal held after its rows are gone, for
revoke_principal_ownership.
Unbounded and unindexed for revoked rows: a cascade read, not a request
path.Source§fn current_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn current_version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The store-wide ownership version:
0 for a fresh store, then whatever
the last row-changing write advanced it to. Equal versions read equal
rows (module docs).Source§fn list_for_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_for_principal<'life0, 'life1, 'async_trait>(
&'life0 self,
p: &'life1 PrincipalId,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Live (non-revoked) rows held by
principal directly — subject
Subject::Principal. Rows reaching it through a subject set are not
included. Unspecified order.Source§fn list_for_resource<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn list_for_resource<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Live (non-revoked) rows over one resource — every principal currently
holding a relationship on
(resource_kind, resource_id), in
unspecified order. Read moreSource§fn list_for_subject_set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn list_for_subject_set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Live (non-revoked) rows whose subject is a set on
(kind, id) — the
tuples conferring their relation on holders of some relation on that
resource (<resource>#<rel> ← kind/id#<subject_relation>), whatever
subject_relation is. Unspecified order. Backed by a partial index on
(subject_kind, subject_id).Source§fn list_for_kind<'life0, 'life1, 'async_trait>(
&'life0 self,
kind: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_for_kind<'life0, 'life1, 'async_trait>(
&'life0 self,
kind: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<OwnershipRow>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Live (non-revoked) rows over every resource of
resource_kind,
whatever the subject form, in unspecified order. Unbounded, like its
siblings: meant for one-shot ledger migrations (noisetable R803-T1
re-keys every publish-scope row to namespace), not request paths.Source§fn revocation_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<RevocationKey, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn revocation_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<RevocationKey, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The membership-revocation key of
(resource_kind, resource_id),
created on first use (R732-T10; cheers_core::revocation, “Membership
privacy”). Immutable: once a key exists every call returns it, so
an edge holding an old snapshot keeps matching new entries — a changed
key would fail revocation open, silently. Get-or-create is insert-or-
ignore of a fresh new_revocation_key followed by a reread, so two
concurrent creators converge on the one row that won. Kept beside the
ownership rows so a restore cannot separate the two. Secret: it goes
out only inside signed snapshots, never on an unauthenticated route.Source§fn admission_policy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AdmissionPolicy>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn admission_policy<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AdmissionPolicy>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The admission policy row of
(resource_kind, resource_id) (R734-F3,
migration 0016). None when the resource has none, which reads as
closed for offline admits.Source§fn set_admission_policy<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
policy: Option<&'life3 AdmissionPolicy>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn set_admission_policy<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
kind: &'life1 str,
id: &'life2 str,
policy: Option<&'life3 AdmissionPolicy>,
now: i64,
) -> Pin<Box<dyn Future<Output = Result<u64, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Set (
Some) or delete (None) the admission policy row, advancing the
ownership version in the same transaction, so the next snapshot carries
the change at a higher epoch. Always advances, even when the value is
unchanged. Returns the version it produced.Auto Trait Implementations§
impl Freeze for MemoryOwnershipStore
impl RefUnwindSafe for MemoryOwnershipStore
impl Send for MemoryOwnershipStore
impl Sync for MemoryOwnershipStore
impl Unpin for MemoryOwnershipStore
impl UnsafeUnpin for MemoryOwnershipStore
impl UnwindSafe for MemoryOwnershipStore
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