pub struct SealedState { /* private fields */ }Expand description
Sealed key/value container with set-once semantics.
Each key can be written exactly once via put_once() or put_sensitive_once().
After that, the key is immutable for the container’s lifetime.
Consumers generally receive &SealedState (read-only), so the Rust borrow checker
guarantees no writes occur during execution.
§Sensitive keys
Keys set via set_sensitive() are redacted in Debug output.
Use this for tokens, secrets, and other credentials.
§No Serialize
SealedState intentionally does not implement Serialize,
preventing accidental persistence. This is enforced at compile time.
Implementations§
Source§impl SealedState
impl SealedState
Sourcepub fn put_once(
&mut self,
key: impl Into<String>,
value: impl Serialize,
) -> Result<(), SealedStateError>
pub fn put_once( &mut self, key: impl Into<String>, value: impl Serialize, ) -> Result<(), SealedStateError>
Set a key once. Returns error if key already exists.
Sourcepub fn put_sensitive_once(
&mut self,
key: impl Into<String>,
value: impl Serialize,
) -> Result<(), SealedStateError>
pub fn put_sensitive_once( &mut self, key: impl Into<String>, value: impl Serialize, ) -> Result<(), SealedStateError>
Set a sensitive key once (redacted in Debug).
Sourcepub fn set(
&mut self,
key: impl Into<String>,
value: impl Serialize,
) -> Result<(), SealedStateError>
pub fn set( &mut self, key: impl Into<String>, value: impl Serialize, ) -> Result<(), SealedStateError>
Backward-compatible alias for put_once.
Sourcepub fn set_sensitive(
&mut self,
key: impl Into<String>,
value: impl Serialize,
) -> Result<(), SealedStateError>
pub fn set_sensitive( &mut self, key: impl Into<String>, value: impl Serialize, ) -> Result<(), SealedStateError>
Backward-compatible alias for put_sensitive_once.
Sourcepub fn get<T: State>(&self) -> T::Ref<'_>
pub fn get<T: State>(&self) -> T::Ref<'_>
Get a typed state reference (same API as ctx.state::<T>()).
Returns a read-only StateRef backed by the sealed document.
Any write through this ref will panic (read-only sink).
Sourcepub fn get_at<T: State>(&self, path: &str) -> T::Ref<'_>
pub fn get_at<T: State>(&self, path: &str) -> T::Ref<'_>
Get a typed state reference at a dot-separated path.
Sourcepub fn value_at(&self, path: &str) -> Option<&Value>
pub fn value_at(&self, path: &str) -> Option<&Value>
Get a raw JSON value at a dot-separated path.
Sourcepub fn is_sensitive(&self, key: &str) -> bool
pub fn is_sensitive(&self, key: &str) -> bool
Check if a key is marked sensitive.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if the container has a key.
Trait Implementations§
Source§impl Clone for SealedState
impl Clone for SealedState
Source§fn clone(&self) -> SealedState
fn clone(&self) -> SealedState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more