Skip to main content

MemoryOwnershipStore

Struct MemoryOwnershipStore 

Source
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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryOwnershipStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryOwnershipStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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,

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,

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,

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,

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,

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,

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,

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,

Live (non-revoked) rows over one resource — every principal currently holding a relationship on (resource_kind, resource_id), in unspecified order. Read more
Source§

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,

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,

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,

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,

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more