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 key-value state store for 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)

Sets a key-value pair in the state.

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§