aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/dispatch.rs2
-rw-r--r--src/ext/voice/connection.rs16
-rw-r--r--src/ext/voice/handler.rs2
-rw-r--r--src/ext/voice/threading.rs4
-rw-r--r--src/model/permissions.rs54
-rw-r--r--src/model/user.rs3
6 files changed, 40 insertions, 41 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs
index fd46394..b4b0302 100644
--- a/src/client/dispatch.rs
+++ b/src/client/dispatch.rs
@@ -296,7 +296,7 @@ fn handle_event(event: Event,
thread::spawn(move || (handler)(context, event));
}}
} else {
- let _ = update!(update_with_guild_member_update, event);
+ update!(update_with_guild_member_update, event);
}
},
Event::GuildMembersChunk(event) => {
diff --git a/src/ext/voice/connection.rs b/src/ext/voice/connection.rs
index 1b2569d..db254a4 100644
--- a/src/ext/voice/connection.rs
+++ b/src/ext/voice/connection.rs
@@ -96,7 +96,7 @@ impl Connection {
hello
};
- if !has_valid_mode(hello.modes) {
+ if !has_valid_mode(&hello.modes) {
return Err(Error::Voice(VoiceError::VoiceModeUnavailable));
}
@@ -220,7 +220,7 @@ impl Connection {
}
} else {
loop {
- if let Err(_) = self.thread_items.rx.try_recv() {
+ if self.thread_items.rx.try_recv().is_err() {
break;
}
}
@@ -411,7 +411,7 @@ fn get_encryption_key(receiver: &mut WsReceiver<WebSocketStream>)
}
#[inline]
-fn has_valid_mode(modes: Vec<String>) -> bool {
+fn has_valid_mode(modes: &[String]) -> bool {
modes.iter().any(|s| s == CRYPTO_MODE)
}
@@ -437,13 +437,13 @@ fn start_threads(mut receiver: WsReceiver<WebSocketStream>, udp: &UdpSocket)
loop {
if let Ok((len, _)) = udp_clone.recv_from(&mut buffer) {
- let piece = buffer[..len].iter().cloned().collect();
+ let piece = buffer[..len].to_vec();
let send = tx.send(ReceiverStatus::Udp(piece));
- if let Err(_) = send {
+ if send.is_err() {
return;
}
- } else if let Ok(_) = udp_close_reader.try_recv() {
+ } else if udp_close_reader.try_recv().is_ok() {
return;
}
}
@@ -454,12 +454,12 @@ fn start_threads(mut receiver: WsReceiver<WebSocketStream>, udp: &UdpSocket)
.spawn(move || {
loop {
while let Ok(msg) = receiver.recv_json(VoiceEvent::decode) {
- if let Err(_) = tx_clone.send(ReceiverStatus::Websocket(msg)) {
+ if tx_clone.send(ReceiverStatus::Websocket(msg)).is_ok() {
return;
}
}
- if let Ok(_) = ws_close_reader.try_recv() {
+ if ws_close_reader.try_recv().is_ok() {
return;
}
diff --git a/src/ext/voice/handler.rs b/src/ext/voice/handler.rs
index cb5838c..60cc6e6 100644
--- a/src/ext/voice/handler.rs
+++ b/src/ext/voice/handler.rs
@@ -220,7 +220,7 @@ impl Handler {
/// [`standalone`]: #method.standalone
pub fn leave(&mut self) {
// Only send an update if we were in a voice channel.
- if let Some(_) = self.channel_id {
+ if self.channel_id.is_some() {
self.channel_id = None;
self.update();
diff --git a/src/ext/voice/threading.rs b/src/ext/voice/threading.rs
index 3986f48..4777231 100644
--- a/src/ext/voice/threading.rs
+++ b/src/ext/voice/threading.rs
@@ -10,11 +10,11 @@ pub fn start(guild_id: GuildId, rx: MpscReceiver<Status>) {
ThreadBuilder::new()
.name(name)
- .spawn(move || runner(rx))
+ .spawn(move || runner(&rx))
.expect(&format!("[Voice] Error starting guild: {:?}", guild_id));
}
-fn runner(rx: MpscReceiver<Status>) {
+fn runner(rx: &MpscReceiver<Status>) {
let mut sender = None;
let mut receiver = None;
let mut connection = None;
diff --git a/src/model/permissions.rs b/src/model/permissions.rs
index 98400c6..b3345eb 100644
--- a/src/model/permissions.rs
+++ b/src/model/permissions.rs
@@ -159,27 +159,27 @@ bitflags! {
/// Allows for the creation of [`RichInvite`]s.
///
/// [`RichInvite`]: ../struct.RichInvite.html
- const CREATE_INVITE = 1 << 0,
+ const CREATE_INVITE = 0b00000000000000000000000000000001,
/// Allows for the kicking of guild [member]s.
///
/// [member]: ../struct.Member.html
- const KICK_MEMBERS = 1 << 1,
+ const KICK_MEMBERS = 0b00000000000000000000000000000010,
/// Allows the banning of guild [member]s.
///
/// [member]: ../struct.Member.html
- const BAN_MEMBERS = 1 << 2,
+ const BAN_MEMBERS = 0b00000000000000000000000000000100,
/// Allows all permissions, bypassing channel [permission overwrite]s.
///
/// [permission overwrite]: ../struct.PermissionOverwrite.html
- const ADMINISTRATOR = 1 << 3,
+ const ADMINISTRATOR = 0b00000000000000000000000000001000,
/// Allows management and editing of guild [channel]s.
///
/// [channel]: ../struct.GuildChannel.html
- const MANAGE_CHANNELS = 1 << 4,
+ const MANAGE_CHANNELS = 0b00000000000000000000000000010000,
/// Allows management and editing of the [guild].
///
/// [guild]: ../struct.Guild.html
- const MANAGE_GUILD = 1 << 5,
+ const MANAGE_GUILD = 0b00000000000000000000000000100000,
/// [`Member`]s with this permission can add new [`Reaction`]s to a
/// [`Message`]. Members can still react using reactions already added
/// to messages without this permission.
@@ -187,68 +187,68 @@ bitflags! {
/// [`Member`]: ../struct.Member.html
/// [`Message`]: ../struct.Message.html
/// [`Reaction`]: ../struct.Reaction.html
- const ADD_REACTIONS = 1 << 6,
+ const ADD_REACTIONS = 0b00000000000000000000000001000000,
/// Allows reading messages in a guild channel. If a user does not have
/// this permission, then they will not be able to see the channel.
- const READ_MESSAGES = 1 << 10,
+ const READ_MESSAGES = 0b00000000000000000000010000000000,
/// Allows sending messages in a guild channel.
- const SEND_MESSAGES = 1 << 11,
+ const SEND_MESSAGES = 0b00000000000000000000100000000000,
/// Allows the sending of text-to-speech messages in a channel.
- const SEND_TTS_MESSAGES = 1 << 12,
+ const SEND_TTS_MESSAGES = 0b00000000000000000001000000000000,
/// Allows the deleting of other messages in a guild channel.
///
/// **Note**: This does not allow the editing of other messages.
- const MANAGE_MESSAGES = 1 << 13,
+ const MANAGE_MESSAGES = 0b00000000000000000010000000000000,
/// Allows links from this user - or users of this role - to be
/// embedded, with potential data such as a thumbnail, description, and
/// page name.
- const EMBED_LINKS = 1 << 14,
+ const EMBED_LINKS = 0b00000000000000000100000000000000,
/// Allows uploading of files.
- const ATTACH_FILES = 1 << 15,
+ const ATTACH_FILES = 0b00000000000000001000000000000000,
/// Allows the reading of a channel's message history.
- const READ_MESSAGE_HISTORY = 1 << 16,
+ const READ_MESSAGE_HISTORY = 0b00000000000000010000000000000000,
/// Allows the usage of the `@everyone` mention, which will notify all
/// users in a channel. The `@here` mention will also be available, and
/// can be used to mention all non-offline users.
///
/// **Note**: You probably want this to be disabled for most roles and
/// users.
- const MENTION_EVERYONE = 1 << 17,
+ const MENTION_EVERYONE = 0b00000000000000100000000000000000,
/// Allows the usage of custom emojis from other guilds.
///
/// This does not dictate whether custom emojis in this guild can be
/// used in other guilds.
- const USE_EXTERNAL_EMOJIS = 1 << 18,
+ const USE_EXTERNAL_EMOJIS = 0b00000000000001000000000000000000,
/// Allows the joining of a voice channel.
- const CONNECT = 1 << 20,
+ const CONNECT = 0b00000000000100000000000000000000,
/// Allows the user to speak in a voice channel.
- const SPEAK = 1 << 21,
+ const SPEAK = 0b00000000001000000000000000000000,
/// Allows the muting of members in a voice channel.
- const MUTE_MEMBERS = 1 << 22,
+ const MUTE_MEMBERS = 0b00000000010000000000000000000000,
/// Allows the deafening of members in a voice channel.
- const DEAFEN_MEMBERS = 1 << 23,
+ const DEAFEN_MEMBERS = 0b00000000100000000000000000000000,
/// Allows the moving of members from one voice channel to another.
- const MOVE_MEMBERS = 1 << 24,
+ const MOVE_MEMBERS = 0b00000001000000000000000000000000,
/// Allows the usage of voice-activity-detection in a [voice] channel.
///
/// If this is disabled, then [`Member`]s must use push-to-talk.
///
/// [`Member`]: ../struct.Member.html
/// [voice]: ../enum.ChannelType.html#variant.Voice
- const USE_VAD = 1 << 25,
+ const USE_VAD = 0b00000010000000000000000000000000,
/// Allows members to change their own nickname in the guild.
- const CHANGE_NICKNAME = 1 << 26,
+ const CHANGE_NICKNAME = 0b00000100000000000000000000000000,
/// Allows members to change other members' nicknames.
- const MANAGE_NICKNAMES = 1 << 27,
+ const MANAGE_NICKNAMES = 0b00001000000000000000000000000000,
/// Allows management and editing of roles below their own.
- const MANAGE_ROLES = 1 << 28,
+ const MANAGE_ROLES = 0b00010000000000000000000000000000,
/// Allows management of webhooks.
- const MANAGE_WEBHOOKS = 1 << 29,
+ const MANAGE_WEBHOOKS = 0b00100000000000000000000000000000,
/// Allows management of emojis created without the use of an
/// [`Integration`].
///
/// [`Integration`]: ../struct.Integration.html
- const MANAGE_EMOJIS = 1 << 30,
+ const MANAGE_EMOJIS = 0b01000000000000000000000000000000,
}
}
diff --git a/src/model/user.rs b/src/model/user.rs
index 338011b..d77275e 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -194,8 +194,7 @@ impl User {
.values()
.map(|ch| ch.read().unwrap())
.find(|ch| ch.recipient.read().unwrap().id == self.id)
- .map(|ch| ch.id)
- .clone();
+ .map(|ch| ch.id);
finding
};