1use super::protocol::*;
24use cfg_if::cfg_if;
25use std::mem;
26
27pub type MsgType = u16;
30pub type DgSizeTag = u16;
31pub type Channel = u64;
32pub type DoId = u32;
33pub type Zone = u32;
34pub type DClassId = u16;
35pub type FieldId = u16;
36pub type DCFileHash = u32; impl From<Protocol> for MsgType {
40 fn from(value: Protocol) -> Self {
41 value as MsgType
42 }
43}
44
45pub const DG_SIZE_MAX: DgSizeTag = u16::MAX;
48pub const CHANNEL_MAX: Channel = u64::MAX;
49pub const DOID_MAX: DoId = u32::MAX;
50pub const ZONE_MAX: Zone = u32::MAX;
51pub const ZONE_BITS: usize = 8 * mem::size_of::<Zone>();
52
53pub const INVALID_DOID: DoId = 0;
56pub const INVALID_CHANNEL: Channel = 0;
57pub const CONTROL_CHANNEL: Channel = 1;
58pub const BCHAN_CLIENTS: Channel = 10;
59pub const BCHAN_STATESERVERS: Channel = 12;
60pub const BCHAN_DBSERVERS: Channel = 13;
61
62cfg_if! {
65 if #[cfg(feature = "dcfile")] {
66 pub static HISTORICAL_DC_KEYWORDS: &[&str] = &[
68 "ram", "required", "db", "airecv", "ownrecv",
69 "clrecv", "broadcast", "ownsend", "clsend",
70 ];
71 pub static DC_VIEW_SUFFIXES: &[&str] = &["AI", "OV", "UD"];
72 pub static MAX_PRIME_NUMBERS: u16 = 10000;
73 }
74}
75
76#[cfg(test)]
77mod tests {
78 use super::*;
79
80 #[test]
81 fn msgtype_from_impl() {
82 assert_eq!(MsgType::from(Protocol::MDRemoveChannel), 9001);
83 assert_eq!(MsgType::from(Protocol::CAAddInterest), 1200);
84 assert_eq!(MsgType::from(Protocol::SSDeleteAIObjects), 2009);
85 }
86}