diff options
| author | Austin Hellyer <[email protected]> | 2016-11-24 11:26:15 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-24 11:26:15 -0800 |
| commit | 290111a02f59f278374a482a8c8df12147ba4ea9 (patch) | |
| tree | a27137c29deb678557122119c882c84963d89604 /src/model | |
| parent | Ignore WebSocketError::NoDataAvailable (diff) | |
| download | serenity-290111a02f59f278374a482a8c8df12147ba4ea9.tar.xz serenity-290111a02f59f278374a482a8c8df12147ba4ea9.zip | |
Rename guild structs to Guild and PartialGuild
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel.rs | 2 | ||||
| -rw-r--r-- | src/model/gateway.rs | 12 | ||||
| -rw-r--r-- | src/model/guild.rs | 24 | ||||
| -rw-r--r-- | src/model/id.rs | 12 | ||||
| -rw-r--r-- | src/model/mod.rs | 2 | ||||
| -rw-r--r-- | src/model/permissions.rs | 2 |
6 files changed, 27 insertions, 27 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs index d00bec5..f34eea0 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -888,7 +888,7 @@ impl PublicChannel { /// **Note**: Right now this performs a clone of the guild. This will be /// optimized in the future. #[cfg(all(feature = "cache", feature = "methods"))] - pub fn guild(&self) -> Option<LiveGuild> { + pub fn guild(&self) -> Option<Guild> { CACHE.read().unwrap().get_guild(self.guild_id).cloned() } diff --git a/src/model/gateway.rs b/src/model/gateway.rs index 113bb2f..d12205b 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -87,12 +87,12 @@ pub struct GuildBanRemoveEvent { #[derive(Clone, Debug)] pub struct GuildCreateEvent { - pub guild: LiveGuild, + pub guild: Guild, } #[derive(Clone, Debug)] pub struct GuildDeleteEvent { - pub guild: Guild, + pub guild: PartialGuild, } #[derive(Clone, Debug)] @@ -165,7 +165,7 @@ pub struct GuildUnavailableEvent { #[derive(Clone, Debug)] pub struct GuildUpdateEvent { - pub guild: Guild, + pub guild: PartialGuild, } #[derive(Clone, Copy, Debug)] @@ -555,7 +555,7 @@ impl Event { })) } else { Ok(Event::GuildCreate(GuildCreateEvent { - guild: try!(LiveGuild::decode(Value::Object(value))), + guild: try!(Guild::decode(Value::Object(value))), })) } } else if kind == "GUILD_DELETE" { @@ -565,7 +565,7 @@ impl Event { })) } else { Ok(Event::GuildDelete(GuildDeleteEvent { - guild: try!(Guild::decode(Value::Object(value))), + guild: try!(PartialGuild::decode(Value::Object(value))), })) } } else if kind == "GUILD_EMOJIS_UPDATE" { @@ -623,7 +623,7 @@ impl Event { })) } else if kind == "GUILD_UPDATE" { Ok(Event::GuildUpdate(GuildUpdateEvent { - guild: try!(Guild::decode(Value::Object(value))), + guild: try!(PartialGuild::decode(Value::Object(value))), })) } else if kind == "MESSAGE_ACK" { missing!(value, Event::MessageAck(MessageAckEvent { diff --git a/src/model/guild.rs b/src/model/guild.rs index bfe29d2..121521c 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -28,8 +28,8 @@ use ::client::http; #[cfg(feature = "cache")] use ::client::CACHE; -impl From<Guild> for GuildContainer { - fn from(guild: Guild) -> GuildContainer { +impl From<PartialGuild> for GuildContainer { + fn from(guild: PartialGuild) -> GuildContainer { GuildContainer::Guild(guild) } } @@ -126,7 +126,7 @@ impl GuildInfo { } } -impl Guild { +impl PartialGuild { /// Finds a role by Id within the guild. #[cfg(feature = "methods")] pub fn find_role<R: Into<RoleId>>(&self, role_id: R) -> Option<&Role> { @@ -164,7 +164,7 @@ impl Guild { } } -impl LiveGuild { +impl Guild { #[cfg(feature = "cache")] fn has_perms(&self, mut permissions: Permissions) -> Result<bool> { let member = match self.get_member(CACHE.read().unwrap().user.id) { @@ -322,7 +322,7 @@ impl LiveGuild { } #[doc(hidden)] - pub fn decode(value: Value) -> Result<LiveGuild> { + pub fn decode(value: Value) -> Result<Guild> { let mut map = try!(into_map(value)); let id = try!(remove(&mut map, "id").and_then(GuildId::decode)); @@ -340,7 +340,7 @@ impl LiveGuild { public_channels }; - missing!(map, LiveGuild { + missing!(map, Guild { afk_channel_id: try!(opt(&mut map, "afk_channel_id", ChannelId::decode)), afk_timeout: req!(try!(remove(&mut map, "afk_timeout")).as_u64()), channels: public_channels, @@ -378,7 +378,7 @@ impl LiveGuild { /// /// [`ClientError::InvalidUser`]: ../client/enum.ClientError.html#variant.InvalidUser #[cfg(feature = "methods")] - pub fn delete(&self) -> Result<Guild> { + pub fn delete(&self) -> Result<PartialGuild> { if self.owner_id != CACHE.read().unwrap().user.id { let req = permissions::MANAGE_GUILD; @@ -551,7 +551,7 @@ impl LiveGuild { /// Leaves the guild. #[cfg(feature = "methods")] - pub fn leave(&self) -> Result<Guild> { + pub fn leave(&self) -> Result<PartialGuild> { http::leave_guild(self.id.0) } @@ -961,14 +961,14 @@ impl fmt::Display for Member { } } -impl PossibleGuild<LiveGuild> { +impl PossibleGuild<Guild> { #[doc(hidden)] pub fn decode(value: Value) -> Result<Self> { let mut value = try!(into_map(value)); if remove(&mut value, "unavailable").ok().and_then(|v| v.as_bool()).unwrap_or(false) { remove(&mut value, "id").and_then(GuildId::decode).map(PossibleGuild::Offline) } else { - LiveGuild::decode(Value::Object(value)).map(PossibleGuild::Online) + Guild::decode(Value::Object(value)).map(PossibleGuild::Online) } } @@ -983,14 +983,14 @@ impl PossibleGuild<LiveGuild> { } } -impl PossibleGuild<Guild> { +impl PossibleGuild<PartialGuild> { #[doc(hidden)] pub fn decode(value: Value) -> Result<Self> { let mut value = try!(into_map(value)); if remove(&mut value, "unavailable").ok().and_then(|v| v.as_bool()).unwrap_or(false) { remove(&mut value, "id").and_then(GuildId::decode).map(PossibleGuild::Offline) } else { - Guild::decode(Value::Object(value)).map(PossibleGuild::Online) + PartialGuild::decode(Value::Object(value)).map(PossibleGuild::Online) } } diff --git a/src/model/id.rs b/src/model/id.rs index d9c131e..9c9cb4d 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -76,7 +76,7 @@ impl From<Emoji> for EmojiId { impl GuildId { /// Search the cache for the guild. #[cfg(feature="methods")] - pub fn find(&self) -> Option<LiveGuild> { + pub fn find(&self) -> Option<Guild> { CACHE.read().unwrap().get_guild(*self).cloned() } @@ -85,7 +85,7 @@ impl GuildId { /// Note that this will not be a complete guild, as REST does not send /// all data with a guild retrieval. #[cfg(feature="methods")] - pub fn get(&self) -> Result<Guild> { + pub fn get(&self) -> Result<PartialGuild> { http::get_guild(self.0) } @@ -117,8 +117,8 @@ impl GuildId { } } -impl From<Guild> for GuildId { - fn from(guild: Guild) -> GuildId { +impl From<PartialGuild> for GuildId { + fn from(guild: PartialGuild) -> GuildId { guild.id } } @@ -135,8 +135,8 @@ impl From<InviteGuild> for GuildId { } } -impl From<LiveGuild> for GuildId { - fn from(live_guild: LiveGuild) -> GuildId { +impl From<Guild> for GuildId { + fn from(live_guild: Guild) -> GuildId { live_guild.id } } diff --git a/src/model/mod.rs b/src/model/mod.rs index 7f8a6ea..880be42 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -141,7 +141,7 @@ pub enum Channel { /// a guild needs to be retrieved from the cache. pub enum GuildContainer { /// A guild which can have its contents directly searched. - Guild(Guild), + Guild(PartialGuild), /// A guild's id, which can be used to search the cache for a guild. Id(GuildId), } diff --git a/src/model/permissions.rs b/src/model/permissions.rs index c21e441..cb9a061 100644 --- a/src/model/permissions.rs +++ b/src/model/permissions.rs @@ -173,7 +173,7 @@ bitflags! { const MANAGE_CHANNELS = 1 << 4, /// Allows management and editing of the [guild]. /// - /// [guild]: ../struct.LiveGuild.html + /// [guild]: ../struct.Guild.html const MANAGE_GUILD = 1 << 5, /// [`Member`]s with this permission can add new [`Reaction`]s to a /// [`Message`]. Members can still react using reactions already added |