Skip to main content

Scoped

Struct Scoped 

Source
pub struct Scoped<'a, S: TenantScopedStore> { /* private fields */ }
Expand description

A tenant-tagged borrow of a storage handle.

Scoped<'a, S> is produced by Tenanted::scoped. It bundles a borrow of the inner store with a borrow of the active tenant. The activation defines its domain methods via a trait implemented on Scoped<'a, MyStore> (Rust’s orphan rule forbids inherent impls on a foreign type from another crate; the AUTHZ-DATA-2-MACRO layer generates the trait + impl).

§Lifetime

The single 'a lifetime is the shorter of the parent Tenanted<S>’s borrow and the supplied &Tenant. Both must outlive the Scoped. This is what makes “fabricated tenant” and “mismatched tenants” structural failures: the lifetime threads through every call site.

§Public surface

The framework supplies only store, tenant, and boundary. The activation’s own domain methods live in a trait implementation on Scoped<'_, MyStore> inside the activation’s own crate.

§Sealing

  • No fabrication. Constructor is module-private; the only path is Tenanted::scoped.
  • No struct-literal. Fields are module-private.
  • No Default. Not derived.
  • No Deserialize. Not derived; the borrow is not transport.

Implementations§

Source§

impl<'a> Scoped<'a, InMemoryKvStore>

Source

pub fn put(&self, key: &str, value: Vec<u8>)

Insert a value under the active tenant’s namespace.

Source

pub fn get(&self, key: &str) -> Option<Vec<u8>>

Look up a value under the active tenant’s namespace.

Source

pub fn list_keys(&self) -> Vec<String>

List all keys in the active tenant’s namespace.

Source§

impl<'a, S: TenantScopedStore> Scoped<'a, S>

Source

pub fn store(&self) -> &'a S

Borrow the underlying storage handle.

The activation’s domain trait impls on Scoped call this to reach the store’s bare API, paired with tenant to bind the active tenant in queries. There is no path to the bare store that does not require having produced a Scoped, which itself requires a &Tenant.

Source

pub fn tenant(&self) -> &'a Tenant

Borrow the active tenant.

Activation domain methods read this to bind the tenant in every SQL bind, key prefix, namespace, etc.

Source

pub fn boundary(&self) -> TenantBoundary

Return the structural TenantBoundary witness for this scope.

Useful for downstream audit/attestation code that wants a type-level proof that a tenant boundary was crossed.

Trait Implementations§

Source§

impl<'a, S: TenantScopedStore> Debug for Scoped<'a, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for Scoped<'a, S>

§

impl<'a, S> RefUnwindSafe for Scoped<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for Scoped<'a, S>

§

impl<'a, S> Sync for Scoped<'a, S>

§

impl<'a, S> Unpin for Scoped<'a, S>

§

impl<'a, S> UnsafeUnpin for Scoped<'a, S>

§

impl<'a, S> UnwindSafe for Scoped<'a, S>
where S: RefUnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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