pub trait SnapshotSession: Session {
type Snapshot: Send + Sync;
// Required methods
fn snapshot(&self) -> Result<Self::Snapshot, Error>;
fn restore(&mut self, snapshot: &Self::Snapshot) -> Result<(), Error>;
}Expand description
Trait for sessions that support state snapshots.
Snapshots capture the current state of the session so it can be:
- Persisted to disk or a database
- Sent over the network to another process
- Restored later to continue execution
§Snapshot Timing
Snapshots can only be captured when execute() has returned. It is not
possible to snapshot mid-execution (e.g., while Python code is running).
This is a fundamental limitation of JIT-compiled WASM.
§Implementation Note
The recommended approach for snapshots is the WIT export method, where
Python-level state is serialized via pickle and exposed through
snapshot_state() and restore_state() exports in the runtime.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".