Skip to main content

State

Trait State 

Source
pub trait State: Send + Sync {
    // Required methods
    fn get(&self, key: &str) -> Option<Value>;
    fn set(&mut self, key: String, value: Value);
    fn all(&self) -> HashMap<String, Value>;
}
Expand description

Mutable session state with key-value storage.

Implementations persist state across turns within a session.

Required Methods§

Source

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

Returns the value for the given key, or None if not present.

Source

fn set(&mut self, key: String, value: Value)

Set a state value. Implementations should call validate_state_key and reject invalid keys (e.g., by logging a warning or panicking).

Source

fn all(&self) -> HashMap<String, Value>

Returns all key-value pairs in the state.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§