example_persist_session

Function main

Source
pub(crate) fn main() -> Result<()>
Expand description

A simple example to show how to persist a client’s data to be able to restore it.

Restoring a session with encryption without having a persisted store will break the encryption setup and the client will not be able to send or receive encrypted messages, hence the need to persist the session.

To use this, just run cargo run -p example-persist-session, and everything is interactive after that. You might want to set the RUST_LOG environment variable to warn to reduce the noise in the logs. The program exits whenever an unexpected error occurs.

To reset the login, simply delete the folder containing the session file, the location is shown in the logs. Note that the database must be deleted too as it can’t be reused.