Expand description
Pluggable session storage backend.
§What changed vs the original
| Before | After |
|---|---|
Only save(PersistedSession) + load(): full round-trip for every change | New update_dc, set_home_dc, update_state allow granular writes |
All methods sync (io::Result) | New methods are async (optional; default impls fall back to save/load) |
| No way to update a single DC key without touching everything else | update_dc only rewrites what changed |
§Backward compatibility
The existing SessionBackend trait is unchanged. The new methods have
default implementations that call load → mutate → save, so existing
backends (BinaryFileBackend, InMemoryBackend, SqliteBackend,
LibSqlBackend) continue to compile and work without modification.
High-performance backends (e.g. a future Redis backend) can override the granular methods to avoid the load/save round-trip.
§Ported from
’ Session trait (in -session/src/session.rs) exposes:
home_dc_id() -> i32: cheap sync readset_home_dc_id(dc_id) -> BoxFuture<'_, ()>: async writedc_option(dc_id) -> Option<DcOption>: cheap sync readset_dc_option(&DcOption) -> BoxFuture<'_, ()>: async writeupdates_state() -> BoxFuture<UpdatesState>: async readset_update_state(UpdateState) -> BoxFuture<()>: fine-grained async write
We adopt the same pattern while keeping layer’s PersistedSession struct.
Structs§
- Binary
File Backend - Stores the session in a compact binary file (v2 format).
- InMemory
Backend - Ephemeral in-process session: nothing persisted to disk.
- Sqlite
Backend sqlite-session - SQLite-backed session (via
rusqlite). - String
Session Backend - Portable base64 string session backend.
Enums§
- Update
State Change - A single update-sequence change, applied via
SessionBackend::apply_update_state.
Traits§
- Session
Backend - Synchronous snapshot backend: saves and loads the full session at once.