equal
deleted
inserted
replaced
62 Delete(String), |
62 Delete(String), |
63 SaveRoom(String), |
63 SaveRoom(String), |
64 LoadRoom(String), |
64 LoadRoom(String), |
65 Malformed, |
65 Malformed, |
66 Empty, |
66 Empty, |
|
67 } |
|
68 |
|
69 #[derive(Debug)] |
|
70 pub enum ProtocolFlags { |
|
71 InRoom, |
|
72 RoomMaster, |
|
73 Ready, |
|
74 InGame, |
|
75 Authenticated, |
|
76 Admin, |
|
77 Contributor, |
|
78 } |
|
79 |
|
80 impl ProtocolFlags { |
|
81 #[inline] |
|
82 fn flag_char(&self) -> char { |
|
83 match self { |
|
84 ProtocolFlags::InRoom => 'i', |
|
85 ProtocolFlags::RoomMaster => 'h', |
|
86 ProtocolFlags::Ready => 'r', |
|
87 ProtocolFlags::InGame => 'g', |
|
88 ProtocolFlags::Authenticated => 'u', |
|
89 ProtocolFlags::Admin => 'a', |
|
90 ProtocolFlags::Contributor => 'c', |
|
91 } |
|
92 } |
|
93 |
|
94 #[inline] |
|
95 fn format(prefix: char, flags: &[ProtocolFlags]) -> String { |
|
96 once(prefix) |
|
97 .chain(flags.iter().map(|f| f.flag_char())) |
|
98 .collect() |
|
99 } |
|
100 } |
|
101 |
|
102 #[inline] |
|
103 pub fn add_flags(flags: &[ProtocolFlags]) -> String { |
|
104 ProtocolFlags::format('+', flags) |
|
105 } |
|
106 |
|
107 #[inline] |
|
108 pub fn remove_flags(flags: &[ProtocolFlags]) -> String { |
|
109 ProtocolFlags::format('-', flags) |
67 } |
110 } |
68 |
111 |
69 #[derive(Debug)] |
112 #[derive(Debug)] |
70 pub enum HWServerMessage { |
113 pub enum HWServerMessage { |
71 Ping, |
114 Ping, |