From 15dd1b5b5483e657ec2346683a07c2e2f458c28b Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sun, 2 Jun 2019 09:49:56 -0700 Subject: [PATCH] Add a session accessor to the client. --- src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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")]