Skip to main content

ScopedStateView

Struct ScopedStateView 

Source
pub struct ScopedStateView<'a> { /* private fields */ }
Expand description

Tenant-scoped view over a StateStore. All key arguments are transparently prefixed with tenant:<tenant_id>: before hitting the underlying store; on the way out, the prefix is stripped so callers see their original keys.

Construct via StateStore::scoped. When tenant is None, the prefix is empty and the view is functionally equivalent to the unscoped methods on StateStore — useful for code paths that always go through this view regardless of whether scope is active.

§Isolation guarantee

Two views with distinct tenant strings cannot observe each other’s writes through get / exists / keys. The transitions log still records the full (prefixed) key so audit / replay sees the actual storage layout.

§What isolation does not cover (phase 3 follow-ups)

  • StateStore::snapshot / restore are deliberately unscoped — they’re called at proposal boundaries for rollback and need to see the whole map. Per-tenant partial rollback is a known concurrency hole when multiple proposals run interleaved; the pre-#187 baseline has the same issue, and fixing it cleanly requires either serializing per-tenant or extending the transactional model. Tracked as a follow-up.
  • The journal file (when durability is on) records full prefixed keys. Operators rotating tenants out can grep the journal by prefix.

Implementations§

Source§

impl<'a> ScopedStateView<'a>

Source

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

Source

pub fn get_or(&self, key: &str, default: Value) -> Value

Source

pub fn exists(&self, key: &str) -> bool

Source

pub fn set(&self, key: &str, value: Value, action_id: &str) -> StateTransition

Source

pub fn set_with_ttl( &self, key: &str, value: Value, action_id: &str, ttl_secs: u64, ) -> StateTransition

Source

pub fn delete(&self, key: &str, action_id: &str) -> Option<StateTransition>

Source

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

Return keys belonging to this tenant only, with the tenant:<id>: prefix stripped so callers see their original key names. Unscoped views (no tenant) return only keys that don’t start with tenant: — preventing accidental visibility of scoped state through a legacy code path.

Auto Trait Implementations§

§

impl<'a> Freeze for ScopedStateView<'a>

§

impl<'a> !RefUnwindSafe for ScopedStateView<'a>

§

impl<'a> Send for ScopedStateView<'a>

§

impl<'a> Sync for ScopedStateView<'a>

§

impl<'a> Unpin for ScopedStateView<'a>

§

impl<'a> UnsafeUnpin for ScopedStateView<'a>

§

impl<'a> !UnwindSafe for ScopedStateView<'a>

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