Add a session accessor to the client.

This commit is contained in:
Jimmy Cuadra 2019-06-02 09:49:56 -07:00
parent 71e1df7063
commit 15dd1b5b54

View File

@ -80,6 +80,17 @@ impl Client<HttpConnector> {
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<Session> {
self.0
.session
.lock()
.expect("session mutex was poisoned")
.clone()
}
}
#[cfg(feature = "tls")]