Skip to main content

recon_core/
node.rs

1//! Process identity.
2
3use core::fmt;
4use serde::{Deserialize, Serialize};
5
6/// Identifies a process in the system.
7///
8/// Copy and totally ordered, so collections keyed by it iterate deterministically and
9/// membership sets can be enumerated in a stable order.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
11pub struct NodeId(pub u64);
12
13impl NodeId {
14    pub const fn new(n: u64) -> Self {
15        NodeId(n)
16    }
17}
18
19impl fmt::Display for NodeId {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        write!(f, "n{}", self.0)
22    }
23}