Skip to main content

ruccl/global/
base.rs

1use serde::{Deserialize, Serialize};
2
3/// Unique identifier for any node in the global collective.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
5pub struct NodeId(u32);
6
7impl From<u32> for NodeId {
8    fn from(value: u32) -> Self {
9        Self(value)
10    }
11}
12
13impl From<usize> for NodeId {
14    fn from(value: usize) -> Self {
15        Self(value as u32)
16    }
17}
18
19impl From<i32> for NodeId {
20    fn from(value: i32) -> Self {
21        Self(value as u32)
22    }
23}