aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-08-18 16:14:32 -0700
committerZeyla Hellyer <[email protected]>2017-08-18 17:52:53 -0700
commite4113570967a1fb13539efbfa2cf7285b19d95ba (patch)
tree06bb020fcfaa5f8323454dfb525272314a900186 /src/model/channel
parentMove Clippy lints to a cfg_attr (diff)
downloadserenity-e4113570967a1fb13539efbfa2cf7285b19d95ba.tar.xz
serenity-e4113570967a1fb13539efbfa2cf7285b19d95ba.zip
Apply rustfmt
Diffstat (limited to 'src/model/channel')
-rw-r--r--src/model/channel/channel_id.rs8
-rw-r--r--src/model/channel/group.rs15
-rw-r--r--src/model/channel/guild_channel.rs13
-rw-r--r--src/model/channel/message.rs29
-rw-r--r--src/model/channel/mod.rs42
-rw-r--r--src/model/channel/private_channel.rs8
-rw-r--r--src/model/channel/reaction.rs3
7 files changed, 78 insertions, 40 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs
index 1c7eb46..d8ccc71 100644
--- a/src/model/channel/channel_id.rs
+++ b/src/model/channel/channel_id.rs
@@ -306,9 +306,11 @@ impl ChannelId {
None => return None,
} {
Guild(channel) => channel.read().unwrap().name().to_string(),
- Group(channel) => match channel.read().unwrap().name() {
- Cow::Borrowed(name) => name.to_string(),
- Cow::Owned(name) => name,
+ Group(channel) => {
+ match channel.read().unwrap().name() {
+ Cow::Borrowed(name) => name.to_string(),
+ Cow::Owned(name) => name,
+ }
},
Private(channel) => channel.read().unwrap().name(),
})
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index 11d6162..7007ad6 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -123,8 +123,11 @@ impl Group {
reaction_type: R)
-> Result<()>
where M: Into<MessageId>, R: Into<ReactionType> {
- self.channel_id
- .delete_reaction(message_id, user_id, reaction_type)
+ self.channel_id.delete_reaction(
+ message_id,
+ user_id,
+ reaction_type,
+ )
}
/// Edits a [`Message`] in the channel given its Id.
@@ -242,8 +245,12 @@ impl Group {
after: Option<U>)
-> Result<Vec<User>>
where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
- self.channel_id
- .reaction_users(message_id, reaction_type, limit, after)
+ self.channel_id.reaction_users(
+ message_id,
+ reaction_type,
+ limit,
+ after,
+ )
}
/// Removes a recipient from the group. If the recipient is already not in
diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs
index 5706fa6..3fadd72 100644
--- a/src/model/channel/guild_channel.rs
+++ b/src/model/channel/guild_channel.rs
@@ -311,7 +311,10 @@ impl GuildChannel {
}
let mut map = Map::new();
- map.insert("name".to_owned(), Value::String(self.name.clone()));
+ map.insert(
+ "name".to_owned(),
+ Value::String(self.name.clone()),
+ );
map.insert(
"position".to_owned(),
Value::Number(Number::from(self.position)),
@@ -540,8 +543,12 @@ impl GuildChannel {
after: Option<U>)
-> Result<Vec<User>>
where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
- self.id
- .reaction_users(message_id, reaction_type, limit, after)
+ self.id.reaction_users(
+ message_id,
+ reaction_type,
+ limit,
+ after,
+ )
}
/// Sends a message with just the given message content in the channel.
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index 6fdab2a..fb8fbaa 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -290,9 +290,10 @@ impl Message {
}
// And finally replace everyone and here mentions.
- result
- .replace("@everyone", "@\u{200B}everyone")
- .replace("@here", "@\u{200B}here")
+ result.replace("@everyone", "@\u{200B}everyone").replace(
+ "@here",
+ "@\u{200B}here",
+ )
}
/// Gets the list of [`User`]s who have reacted to a [`Message`] with a
@@ -318,8 +319,12 @@ impl Message {
after: Option<U>)
-> Result<Vec<User>>
where R: Into<ReactionType>, U: Into<UserId> {
- self.channel_id
- .reaction_users(self.id, reaction_type, limit, after)
+ self.channel_id.reaction_users(
+ self.id,
+ reaction_type,
+ limit,
+ after,
+ )
}
/// Returns the associated `Guild` for the message if one is in the cache.
@@ -332,8 +337,9 @@ impl Message {
/// [`guild_id`]: #method.guild_id
#[cfg(feature = "cache")]
pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> {
- self.guild_id()
- .and_then(|guild_id| CACHE.read().unwrap().guild(guild_id))
+ self.guild_id().and_then(|guild_id| {
+ CACHE.read().unwrap().guild(guild_id)
+ })
}
/// Retrieves the Id of the guild that the message was sent in, if sent in
@@ -353,7 +359,8 @@ impl Message {
#[cfg(feature = "cache")]
pub fn is_private(&self) -> bool {
match CACHE.read().unwrap().channel(self.channel_id) {
- Some(Channel::Group(_)) | Some(Channel::Private(_)) => true,
+ Some(Channel::Group(_)) |
+ Some(Channel::Private(_)) => true,
_ => false,
}
}
@@ -370,11 +377,7 @@ impl Message {
let count = content.chars().count() as i64;
let diff = count - (constants::MESSAGE_CODE_LIMIT as i64);
- if diff > 0 {
- Some(diff as u64)
- } else {
- None
- }
+ if diff > 0 { Some(diff as u64) } else { None }
}
/// Pins this message to its channel.
diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs
index cbe6085..626f466 100644
--- a/src/model/channel/mod.rs
+++ b/src/model/channel/mod.rs
@@ -117,8 +117,11 @@ impl Channel {
reaction_type: R)
-> Result<()>
where M: Into<MessageId>, R: Into<ReactionType> {
- self.id()
- .delete_reaction(message_id, user_id, reaction_type)
+ self.id().delete_reaction(
+ message_id,
+ user_id,
+ reaction_type,
+ )
}
/// Edits a [`Message`] in the channel given its Id.
@@ -156,7 +159,8 @@ impl Channel {
pub fn is_nsfw(&self) -> bool {
match *self {
Channel::Guild(ref channel) => channel.read().unwrap().is_nsfw(),
- Channel::Group(_) | Channel::Private(_) => false,
+ Channel::Group(_) |
+ Channel::Private(_) => false,
}
}
@@ -216,8 +220,12 @@ impl Channel {
after: Option<U>)
-> Result<Vec<User>>
where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
- self.id()
- .reaction_users(message_id, reaction_type, limit, after)
+ self.id().reaction_users(
+ message_id,
+ reaction_type,
+ limit,
+ after,
+ )
}
/// Retrieves the Id of the inner [`Group`], [`GuildChannel`], or
@@ -318,15 +326,21 @@ impl<'de> Deserialize<'de> for Channel {
};
match kind {
- 0 | 2 => serde_json::from_value::<GuildChannel>(Value::Object(v))
- .map(|x| Channel::Guild(Arc::new(RwLock::new(x))))
- .map_err(DeError::custom),
- 1 => serde_json::from_value::<PrivateChannel>(Value::Object(v))
- .map(|x| Channel::Private(Arc::new(RwLock::new(x))))
- .map_err(DeError::custom),
- 3 => serde_json::from_value::<Group>(Value::Object(v))
- .map(|x| Channel::Group(Arc::new(RwLock::new(x))))
- .map_err(DeError::custom),
+ 0 | 2 => {
+ serde_json::from_value::<GuildChannel>(Value::Object(v))
+ .map(|x| Channel::Guild(Arc::new(RwLock::new(x))))
+ .map_err(DeError::custom)
+ },
+ 1 => {
+ serde_json::from_value::<PrivateChannel>(Value::Object(v))
+ .map(|x| Channel::Private(Arc::new(RwLock::new(x))))
+ .map_err(DeError::custom)
+ },
+ 3 => {
+ serde_json::from_value::<Group>(Value::Object(v))
+ .map(|x| Channel::Group(Arc::new(RwLock::new(x))))
+ .map_err(DeError::custom)
+ },
_ => Err(DeError::custom("Unknown channel type")),
}
}
diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs
index 277c6a1..30dc01d 100644
--- a/src/model/channel/private_channel.rs
+++ b/src/model/channel/private_channel.rs
@@ -191,8 +191,12 @@ impl PrivateChannel {
after: Option<U>)
-> Result<Vec<User>>
where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
- self.id
- .reaction_users(message_id, reaction_type, limit, after)
+ self.id.reaction_users(
+ message_id,
+ reaction_type,
+ limit,
+ after,
+ )
}
/// Pins a [`Message`] to the channel.
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs
index ac522a0..8922182 100644
--- a/src/model/channel/reaction.rs
+++ b/src/model/channel/reaction.rs
@@ -46,7 +46,8 @@ impl Reaction {
/// [Manage Messages]: permissions/constant.MANAGE_MESSAGES.html
/// [permissions]: permissions
pub fn delete(&self) -> Result<()> {
- let user_id = feature_cache! {{
+ let user_id =
+ feature_cache! {{
let user = if self.user_id == CACHE.read().unwrap().user.id {
None
} else {