aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/replica.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/document/replica.rs b/src/document/replica.rs
index fe76c12..c8f648b 100644
--- a/src/document/replica.rs
+++ b/src/document/replica.rs
@@ -59,6 +59,24 @@ impl Epoch {
}
}
+/// An epoch as records and the API show it: its generation and its snapshot hash in
+/// hex (all zeros for the genesis epoch).
+#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct EpochRecord {
+ pub(crate) generation: u64,
+ pub(crate) id: String,
+}
+
+impl From<Epoch> for EpochRecord {
+ fn from(epoch: Epoch) -> Self {
+ Self {
+ generation: epoch.generation,
+ id: epoch.id_hex(),
+ }
+ }
+}
+
impl fmt::Display for Epoch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if *self == Epoch::GENESIS {