mirror of
https://github.com/mikedilger/chorus.git
synced 2026-05-03 06:51:42 +00:00
types: Kind
This commit is contained in:
parent
451987cdfe
commit
2a5d2721f5
28
src/types/kind.rs
Normal file
28
src/types/kind.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub struct Kind(pub u16);
|
||||||
|
|
||||||
|
impl fmt::Display for Kind {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "{}", self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Kind {
|
||||||
|
// Some kinds a relay may need to treat differently
|
||||||
|
pub const SEAL: u16 = 13;
|
||||||
|
pub const DM_CHAT: u16 = 14;
|
||||||
|
|
||||||
|
pub fn is_replaceable(&self) -> bool {
|
||||||
|
(10000..20000).contains(&self.0) || self.0 == 0 || self.0 == 3
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_ephemeral(&self) -> bool {
|
||||||
|
(20000..30000).contains(&self.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_parameterized_replaceable(&self) -> bool {
|
||||||
|
(30000..40000).contains(&self.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,2 +1,5 @@
|
|||||||
mod id;
|
mod id;
|
||||||
pub use id::Id;
|
pub use id::Id;
|
||||||
|
|
||||||
|
mod kind;
|
||||||
|
pub use kind::Kind;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user