relay_knowledge/domain/core/graph_version.rs
1use serde::{Deserialize, Serialize};
2
3/// Monotonic graph state version.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
5pub struct GraphVersion(u64);
6
7impl GraphVersion {
8 /// The empty graph version used before storage is attached.
9 pub const ZERO: Self = Self(0);
10
11 /// Creates a graph version from its numeric representation.
12 pub const fn new(value: u64) -> Self {
13 Self(value)
14 }
15
16 /// Returns the numeric graph version.
17 pub const fn get(self) -> u64 {
18 self.0
19 }
20}
21
22#[cfg(test)]
23#[path = "graph_version_tests.rs"]
24mod tests;