Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_steel/src/srv/id.rs

1.1 KiB, 5 runs

created by r1870400018:989, 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

1use oxedyne_fe2o3_core::prelude::*;
2use oxedyne_fe2o3_jdat::{
3 id::IdDat,
4 kind::Kind,
5};
6
7use std::{
8 fmt,
9 mem,
10};
11
12
13//// Protocol identifier types for defaults and testing.
14pub type BidTyp = u64; // Bot Id
15pub type SidTyp = u64; // State Id (e.g. for sessions)
16pub type UidTyp = u128; // User Id, a default.
17
18pub const UID_KIND: Kind = Kind::U128;
19
20pub const BID_LEN: usize = mem::size_of::<BidTyp>();
21pub const SID_LEN: usize = mem::size_of::<SidTyp>();
22pub const UID_LEN: usize = mem::size_of::<UidTyp>();
23
24pub type Bid = IdDat<{BID_LEN}, BidTyp>;
25pub type Sid = IdDat<{SID_LEN}, SidTyp>;
26pub type Uid = IdDat<{UID_LEN}, UidTyp>;
27
28// Message command identifier.
29new_type!(McidTyp, u64, Clone, Copy);
30
31pub const MCID_KIND: Kind = Kind::U64;
32
33impl fmt::Display for McidTyp {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 write!(f, "{:016x}", self)
36 }
37}
38
39impl fmt::Debug for McidTyp {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 write!(f, "{}", self)
42 }
43}
44
45impl fmt::LowerHex for McidTyp {
46 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47 fmt::LowerHex::fmt(&self.0, f)
48 }
49}