Skip to content

Commit

Permalink
Add missing 'num' implementations on models
Browse files Browse the repository at this point in the history
Add missing 'num' implementations from the following models:

- `channel::{ChannelType, MessageType}`
- `gateway::GameType`
  • Loading branch information
Zeyla Hellyer committed Dec 28, 2017
1 parent 3a0c890 commit 0b1f684
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
10 changes: 10 additions & 0 deletions src/model/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
13 changes: 13 additions & 0 deletions src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down

0 comments on commit 0b1f684

Please sign in to comment.