Skip to main content

SessionStateComponent

Trait SessionStateComponent 

Source
pub trait SessionStateComponent: Send + Sync {
    // Required methods
    fn key(&self) -> &str;
    fn save(&self) -> Value;
    fn load(&self, state: Value) -> Result<()>;
}
Expand description

Handles session persistence for a module’s state.

Modules that need to persist state across sessions should return an implementation of this trait from Module::session_state().

Required Methods§

Source

fn key(&self) -> &str

Unique key for storing this module’s state in session data.

Source

fn save(&self) -> Value

Serialize current state for persistence.

Source

fn load(&self, state: Value) -> Result<()>

Restore state from persisted session data.

Implementors§