mongodb/sync/client/
session.rs1use super::Client;
2use crate::{bson::Document, client::session::ClusterTime, ClientSession as AsyncClientSession};
3
4pub struct ClientSession {
11 pub(crate) async_client_session: AsyncClientSession,
12}
13
14impl From<AsyncClientSession> for ClientSession {
15 fn from(async_client_session: AsyncClientSession) -> Self {
16 Self {
17 async_client_session,
18 }
19 }
20}
21
22impl<'a> From<&'a mut ClientSession> for &'a mut AsyncClientSession {
23 fn from(value: &'a mut ClientSession) -> &'a mut AsyncClientSession {
24 &mut value.async_client_session
25 }
26}
27
28impl ClientSession {
29 pub(crate) fn new(async_client_session: AsyncClientSession) -> Self {
30 Self {
31 async_client_session,
32 }
33 }
34
35 pub fn client(&self) -> Client {
37 self.async_client_session.client().into()
38 }
39
40 pub fn id(&self) -> &Document {
42 self.async_client_session.id()
43 }
44
45 pub fn cluster_time(&self) -> Option<&ClusterTime> {
48 self.async_client_session.cluster_time()
49 }
50
51 pub fn advance_cluster_time(&mut self, to: &ClusterTime) {
54 self.async_client_session.advance_cluster_time(to)
55 }
56}