diff options
| author | Zeyla Hellyer <[email protected]> | 2017-12-27 16:39:45 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-12-27 16:40:42 -0800 |
| commit | 0b1f684106031657d6bf581206c06e5443d06da9 (patch) | |
| tree | bd7a78e5ea5c504068d61a220ceb8b8b2fa46a73 /src | |
| parent | Improve performance of builders even further (diff) | |
| download | serenity-0b1f684106031657d6bf581206c06e5443d06da9.tar.xz serenity-0b1f684106031657d6bf581206c06e5443d06da9.zip | |
Add missing 'num' implementations on models
Add missing 'num' implementations from the following models:
- `channel::{ChannelType, MessageType}`
- `gateway::GameType`
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/channel/message.rs | 17 | ||||
| -rw-r--r-- | src/model/channel/mod.rs | 10 | ||||
| -rw-r--r-- | src/model/gateway.rs | 13 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 315dc24..87385ac 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -617,3 +617,20 @@ enum_number!( MemberJoin = 7, } ); + +impl MessageType { + pub fn num(&self) -> u64 { + use self::MessageType::*; + + match *self { + Regular => 0, + GroupRecipientAddition => 1, + GroupRecipientRemoval => 2, + GroupCallCreation => 3, + GroupNameUpdate => 4, + GroupIconUpdate => 5, + PinsAdd => 6, + MemberJoin => 7, + } + } +} diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 1fe4345..7764fea 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -570,6 +570,16 @@ impl ChannelType { ChannelType::Category => "category", } } + + pub fn num(&self) -> u64 { + match *self { + ChannelType::Text => 0, + ChannelType::Private => 1, + ChannelType::Voice => 2, + ChannelType::Group => 3, + ChannelType::Category => 4, + } + } } #[derive(Deserialize)] diff --git a/src/model/gateway.rs b/src/model/gateway.rs index 27a541b..c097c6f 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -192,6 +192,19 @@ enum_number!( } ); +impl GameType { + pub fn num(&self) -> u64 { + use self::GameType::*; + + match *self { + Playing => 0, + Streaming => 1, + Listening => 2, + Watching => 3, + } + } +} + impl Default for GameType { fn default() -> Self { GameType::Playing } } |