aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-19 20:50:33 -0800
committerAustin Hellyer <[email protected]>2016-11-19 20:50:33 -0800
commit66f4acc63163a5f7bd528165ee5fe9ae7d44eb7d (patch)
tree357b4f4632138b6e0270c177cccd445b1c4f2d98 /src/model
parentFix type errors for non-framework builds (diff)
downloadserenity-66f4acc63163a5f7bd528165ee5fe9ae7d44eb7d.tar.xz
serenity-66f4acc63163a5f7bd528165ee5fe9ae7d44eb7d.zip
Rename state methods from find_ to get_
For consistency with the rest of the library, rename the methods prefixed with `find_` to `get_`. The past logic was that items are "found", as they may or may not exist. With get, the expectation is that it is _always_ there, i.e. over REST. However, this is inconsistent, and "get"ting over REST can fail for other reasons.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/channel.rs2
-rw-r--r--src/model/id.rs9
-rw-r--r--src/model/user.rs2
-rw-r--r--src/model/utils.rs4
4 files changed, 8 insertions, 9 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs
index 07e6939..ddbd565 100644
--- a/src/model/channel.rs
+++ b/src/model/channel.rs
@@ -889,7 +889,7 @@ impl PublicChannel {
/// optimized in the future.
#[cfg(all(feature = "methods", feature = "state"))]
pub fn guild(&self) -> Option<LiveGuild> {
- STATE.lock().unwrap().find_guild(self.guild_id).cloned()
+ STATE.lock().unwrap().get_guild(self.guild_id).cloned()
}
/// Return a [`Mention`] which will link to this channel.
diff --git a/src/model/id.rs b/src/model/id.rs
index 8f925de..8c94dec 100644
--- a/src/model/id.rs
+++ b/src/model/id.rs
@@ -9,15 +9,15 @@ impl ChannelId {
/// Search the state for the channel with the Id.
#[cfg(feature="methods")]
pub fn find(&self) -> Option<Channel> {
- STATE.lock().unwrap().find_channel(*self)
+ STATE.lock().unwrap().get_channel(*self)
}
/// Search the state for the channel. If it can't be found, the channel is
/// requested over REST.
#[cfg(feature="methods")]
pub fn get(&self) -> Result<Channel> {
- if let Some(channel) = STATE.lock().unwrap().find_channel(*self) {
- return Ok(channel);
+ if let Some(channel) = STATE.lock().unwrap().get_channel(*self) {
+ return Ok(channel.clone());
}
http::get_channel(self.0)
@@ -74,11 +74,10 @@ impl From<Emoji> for EmojiId {
}
impl GuildId {
-
/// Search the state for the guild.
#[cfg(feature="methods")]
pub fn find(&self) -> Option<LiveGuild> {
- STATE.lock().unwrap().find_guild(*self).cloned()
+ STATE.lock().unwrap().get_guild(*self).cloned()
}
/// Requests the guild over REST.
diff --git a/src/model/user.rs b/src/model/user.rs
index e4699ce..efe41fd 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -118,7 +118,7 @@ impl User {
feature_state! {{
let state = STATE.lock().unwrap();
- return state.find_role(guild_id, role_id).is_some();
+ return state.get_role(guild_id, role_id).is_some();
} else {
return true;
}}
diff --git a/src/model/utils.rs b/src/model/utils.rs
index 92dfbd9..db39939 100644
--- a/src/model/utils.rs
+++ b/src/model/utils.rs
@@ -278,7 +278,7 @@ pub fn user_has_perms(channel_id: ChannelId,
let state = STATE.lock().unwrap();
let current_user = &state.user;
- let channel = match state.find_channel(channel_id) {
+ let channel = match state.get_channel(channel_id) {
Some(channel) => channel,
None => return Err(Error::Client(ClientError::ItemMissing)),
};
@@ -290,7 +290,7 @@ pub fn user_has_perms(channel_id: ChannelId,
Channel::Public(channel) => channel.guild_id,
};
- let guild = match state.find_guild(guild_id) {
+ let guild = match state.get_guild(guild_id) {
Some(guild) => guild,
None => return Err(Error::Client(ClientError::ItemMissing)),
};