themis/law/epoch.rs
1//! Topology version tokens.
2
3/// Topology version token.
4#[repr(transparent)]
5#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct TopologyEpoch(u64);
7
8impl TopologyEpoch {
9 /// Initial topology epoch.
10 pub const INITIAL: Self = Self(0);
11
12 /// Creates a topology epoch.
13 #[must_use]
14 pub const fn new(raw: u64) -> Self {
15 Self(raw)
16 }
17
18 /// Returns the raw epoch value.
19 #[must_use]
20 pub const fn get(self) -> u64 {
21 self.0
22 }
23
24 /// Returns the next epoch version.
25 #[must_use]
26 pub const fn next(self) -> Self {
27 Self(self.0.wrapping_add(1))
28 }
29}