diff --git a/src/lib.rs b/src/lib.rs index f65274b5..8271cad2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,17 @@ impl Client { session: Mutex::new(session), })) } + + /// Get a copy of the current `Session`, if any. + /// + /// Useful for serializing and persisting the session to be restored later. + pub fn session(&self) -> Option { + self.0 + .session + .lock() + .expect("session mutex was poisoned") + .clone() + } } #[cfg(feature = "tls")]