1use std::fmt;
2
3macro_rules! integer_id {
4 ($(#[$meta:meta])* $name:ident) => {
5 $(#[$meta])*
6 #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
7 pub struct $name(u64);
8
9 impl $name {
10 pub const ZERO: Self = Self(0);
11
12 pub const fn new(value: u64) -> Self {
13 Self(value)
14 }
15
16 pub const fn get(self) -> u64 {
17 self.0
18 }
19 }
20
21 impl fmt::Display for $name {
22 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
23 self.0.fmt(formatter)
24 }
25 }
26 };
27}
28
29integer_id!(
30 TenantId
32);
33integer_id!(
34 ShardId
36);
37integer_id!(
38 ShardEpoch
40);
41integer_id!(
42 PageId
44);
45integer_id!(
46 Lsn
48);
49integer_id!(
50 TxnId
52);
53integer_id!(
54 Revision
56);