Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_social/src/person.rs

849 bytes, 18 runs

created by r1870400018:8811, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//! Person identifiers and profile types for social network simulation.
2
3use oxedyne_fe2o3_core::prelude::*;
4use oxedyne_fe2o3_data::digraph::NodeId;
5
6use std::fmt;
7
8// Person identifier in the social network, allowing a population size of 4.294B.
9new_type!(PersonId, u32, Clone, Copy, Debug, Eq, Hash, PartialEq);
10
11impl NodeId for PersonId {}
12
13impl fmt::Display for PersonId {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(f, "{:#x}", self.0)
16 }
17}
18
19/// Profile types for population segments.
20#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
21pub enum ProfileType {
22 Connected,
23 Isolated,
24 Standard,
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn test_person_id_display() {
33 let id = PersonId(12345);
34 assert_eq!(format!("{}", id), "0x3039"); // 12345 in hex
35 }
36}