mongodb/client/session/
cluster_time.rs

1use derive_where::derive_where;
2use serde::{Deserialize, Serialize};
3
4use crate::bson::{Document, Timestamp};
5
6/// Struct modeling a cluster time reported by the server.
7///
8/// See [the MongoDB documentation](https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/)
9/// for more information.
10#[derive(Debug, Deserialize, Clone, Serialize)]
11#[derive_where(PartialEq, Eq)]
12#[serde(rename_all = "camelCase")]
13pub struct ClusterTime {
14    pub(crate) cluster_time: Timestamp,
15
16    #[derive_where(skip)]
17    pub(crate) signature: Document,
18}
19
20impl std::cmp::Ord for ClusterTime {
21    fn cmp(&self, other: &ClusterTime) -> std::cmp::Ordering {
22        self.cluster_time.cmp(&other.cluster_time)
23    }
24}
25
26impl std::cmp::PartialOrd for ClusterTime {
27    fn partial_cmp(&self, other: &ClusterTime) -> Option<std::cmp::Ordering> {
28        Some(self.cmp(other))
29    }
30}