diff options
| author | acdenisSK <[email protected]> | 2017-07-27 06:42:48 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-27 07:30:23 +0200 |
| commit | 550030264952f0e0043b63f4582bb817ef8bbf37 (patch) | |
| tree | b921e2f78fd603a5ca671623083a32806fd16090 /src/model/guild/partial_guild.rs | |
| parent | Use a consistent indentation style (diff) | |
| download | serenity-550030264952f0e0043b63f4582bb817ef8bbf37.tar.xz serenity-550030264952f0e0043b63f4582bb817ef8bbf37.zip | |
rustfmt
Diffstat (limited to 'src/model/guild/partial_guild.rs')
| -rw-r--r-- | src/model/guild/partial_guild.rs | 112 |
1 files changed, 45 insertions, 67 deletions
diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index 26d4257..d070e54 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -1,8 +1,8 @@ use super::super::utils::{deserialize_emojis, deserialize_roles}; -use ::model::*; +use model::*; -#[cfg(feature="model")] -use ::builder::{EditGuild, EditMember, EditRole}; +#[cfg(feature = "model")] +use builder::{EditGuild, EditMember, EditRole}; /// Partial information about a [`Guild`]. This does not include information /// like member data. @@ -16,7 +16,7 @@ pub struct PartialGuild { pub default_message_notifications: u64, pub embed_channel_id: Option<ChannelId>, pub embed_enabled: bool, - #[serde(deserialize_with="deserialize_emojis")] + #[serde(deserialize_with = "deserialize_emojis")] pub emojis: HashMap<EmojiId, Emoji>, pub features: Vec<Feature>, pub icon: Option<String>, @@ -24,13 +24,13 @@ pub struct PartialGuild { pub name: String, pub owner_id: UserId, pub region: String, - #[serde(deserialize_with="deserialize_roles")] + #[serde(deserialize_with = "deserialize_roles")] pub roles: HashMap<RoleId, Role>, pub splash: Option<String>, pub verification_level: VerificationLevel, } -#[cfg(feature="model")] +#[cfg(feature = "model")] impl PartialGuild { /// Ban a [`User`] from the guild. All messages by the /// user within the last given number of days given will be deleted. This @@ -52,7 +52,8 @@ impl PartialGuild { /// Returns a [`ModelError::DeleteMessageDaysAmount`] if the number of /// days' worth of messages to delete is over the maximum. /// - /// [`ModelError::DeleteMessageDaysAmount`]: enum.ModelError.html#variant.DeleteMessageDaysAmount + /// [`ModelError::DeleteMessageDaysAmount`]: + /// enum.ModelError.html#variant.DeleteMessageDaysAmount /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html pub fn ban<U: Into<UserId>>(&self, user: U, delete_message_days: u8) -> Result<()> { @@ -69,17 +70,13 @@ impl PartialGuild { /// /// [Ban Members]: permissions/constant.BAN_MEMBERS.html #[inline] - pub fn bans(&self) -> Result<Vec<Ban>> { - self.id.bans() - } + pub fn bans(&self) -> Result<Vec<Ban>> { self.id.bans() } /// Gets all of the guild's channels over the REST API. /// /// [`Guild`]: struct.Guild.html #[inline] - pub fn channels(&self) -> Result<HashMap<ChannelId, GuildChannel>> { - self.id.channels() - } + pub fn channels(&self) -> Result<HashMap<ChannelId, GuildChannel>> { self.id.channels() } /// Creates a [`GuildChannel`] in the guild. /// @@ -134,7 +131,8 @@ impl PartialGuild { /// [Manage Guild]: permissions/constant.MANAGE_GUILD.html #[inline] pub fn create_integration<I>(&self, integration_id: I, kind: &str) -> Result<()> - where I: Into<IntegrationId> { + where + I: Into<IntegrationId>, { self.id.create_integration(integration_id, kind) } @@ -162,9 +160,7 @@ impl PartialGuild { /// /// **Note**: Requires the current user to be the owner of the guild. #[inline] - pub fn delete(&self) -> Result<PartialGuild> { - self.id.delete() - } + pub fn delete(&self) -> Result<PartialGuild> { self.id.delete() } /// Deletes an [`Emoji`] from the guild. /// @@ -209,7 +205,8 @@ impl PartialGuild { /// /// [Manage Guild]: permissions/constant.MANAGE_GUILD.html pub fn edit<F>(&mut self, f: F) -> Result<()> - where F: FnOnce(EditGuild) -> EditGuild { + where + F: FnOnce(EditGuild) -> EditGuild, { match self.id.edit(f) { Ok(guild) => { self.afk_channel_id = guild.afk_channel_id; @@ -264,7 +261,9 @@ impl PartialGuild { /// ``` #[inline] pub fn edit_member<F, U>(&self, user_id: U, f: F) -> Result<()> - where F: FnOnce(EditMember) -> EditMember, U: Into<UserId> { + where + F: FnOnce(EditMember) -> EditMember, + U: Into<UserId>, { self.id.edit_member(user_id, f) } @@ -293,9 +292,7 @@ impl PartialGuild { /// /// [Manage Emojis]: permissions/constant.MANAGE_EMOJIS.html #[inline] - pub fn emoji<E: Into<EmojiId>>(&self, emoji_id: E) -> Result<Emoji> { - self.id.emoji(emoji_id) - } + pub fn emoji<E: Into<EmojiId>>(&self, emoji_id: E) -> Result<Emoji> { self.id.emoji(emoji_id) } /// Gets a list of all of the guild's emojis. /// @@ -303,17 +300,13 @@ impl PartialGuild { /// /// [Manage Emojis]: permissions/constant.MANAGE_EMOJIS.html #[inline] - pub fn emojis(&self) -> Result<Vec<Emoji>> { - self.id.emojis() - } + pub fn emojis(&self) -> Result<Vec<Emoji>> { self.id.emojis() } /// Gets a partial amount of guild data by its Id. /// /// Requires that the current user be in the guild. #[inline] - pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { - guild_id.into().get() - } + pub fn get<G: Into<GuildId>>(guild_id: G) -> Result<PartialGuild> { guild_id.into().get() } /// Kicks a [`Member`] from the guild. /// @@ -322,23 +315,20 @@ impl PartialGuild { /// [`Member`]: struct.Member.html /// [Kick Members]: permissions/constant.KICK_MEMBERS.html #[inline] - pub fn kick<U: Into<UserId>>(&self, user_id: U) -> Result<()> { - self.id.kick(user_id) - } + pub fn kick<U: Into<UserId>>(&self, user_id: U) -> Result<()> { self.id.kick(user_id) } /// Returns a formatted URL of the guild's icon, if the guild has an icon. pub fn icon_url(&self) -> Option<String> { - self.icon.as_ref().map(|icon| - format!(cdn!("/icons/{}/{}.webp"), self.id, icon)) + self.icon + .as_ref() + .map(|icon| format!(cdn!("/icons/{}/{}.webp"), self.id, icon)) } /// Gets all integration of the guild. /// /// This performs a request over the REST API. #[inline] - pub fn integrations(&self) -> Result<Vec<Integration>> { - self.id.integrations() - } + pub fn integrations(&self) -> Result<Vec<Integration>> { self.id.integrations() } /// Gets all of the guild's invites. /// @@ -346,23 +336,17 @@ impl PartialGuild { /// /// [Manage Guild]: permissions/constant.MANAGE_GUILD.html #[inline] - pub fn invites(&self) -> Result<Vec<RichInvite>> { - self.id.invites() - } + pub fn invites(&self) -> Result<Vec<RichInvite>> { self.id.invites() } /// Leaves the guild. #[inline] - pub fn leave(&self) -> Result<()> { - self.id.leave() - } + pub fn leave(&self) -> Result<()> { self.id.leave() } /// Gets a user's [`Member`] for the guild by Id. /// /// [`Guild`]: struct.Guild.html /// [`Member`]: struct.Member.html - pub fn member<U: Into<UserId>>(&self, user_id: U) -> Result<Member> { - self.id.member(user_id) - } + pub fn member<U: Into<UserId>>(&self, user_id: U) -> Result<Member> { self.id.member(user_id) } /// Gets a list of the guild's members. /// @@ -371,8 +355,9 @@ impl PartialGuild { /// [`User`]'s Id. /// /// [`User`]: struct.User.html - pub fn members<U>(&self, limit: Option<u64>, after: Option<U>) - -> Result<Vec<Member>> where U: Into<UserId> { + pub fn members<U>(&self, limit: Option<u64>, after: Option<U>) -> Result<Vec<Member>> + where + U: Into<UserId>, { self.id.members(limit, after) } @@ -383,7 +368,9 @@ impl PartialGuild { /// [Move Members]: permissions/constant.MOVE_MEMBERS.html #[inline] pub fn move_member<C, U>(&self, user_id: U, channel_id: C) -> Result<()> - where C: Into<ChannelId>, U: Into<UserId> { + where + C: Into<ChannelId>, + U: Into<UserId>, { self.id.move_member(user_id, channel_id) } @@ -395,9 +382,7 @@ impl PartialGuild { /// [`Member`]: struct.Member.html /// [Kick Members]: permissions/constant.KICK_MEMBERS.html #[inline] - pub fn prune_count(&self, days: u16) -> Result<GuildPrune> { - self.id.prune_count(days) - } + pub fn prune_count(&self, days: u16) -> Result<GuildPrune> { self.id.prune_count(days) } /// Returns the Id of the shard associated with the guild. /// @@ -409,11 +394,9 @@ impl PartialGuild { /// total, consider using [`utils::shard_id`]. /// /// [`utils::shard_id`]: ../utils/fn.shard_id.html - #[cfg(all(feature="cache", feature="utils"))] + #[cfg(all(feature = "cache", feature = "utils"))] #[inline] - pub fn shard_id(&self) -> u64 { - self.id.shard_id() - } + pub fn shard_id(&self) -> u64 { self.id.shard_id() } /// Returns the Id of the shard associated with the guild. /// @@ -435,16 +418,15 @@ impl PartialGuild { /// /// assert_eq!(guild.shard_id(17), 7); /// ``` - #[cfg(all(feature="utils", not(feature="cache")))] + #[cfg(all(feature = "utils", not(feature = "cache")))] #[inline] - pub fn shard_id(&self, shard_count: u64) -> u64 { - self.id.shard_id(shard_count) - } + pub fn shard_id(&self, shard_count: u64) -> u64 { self.id.shard_id(shard_count) } /// Returns the formatted URL of the guild's splash image, if one exists. pub fn splash_url(&self) -> Option<String> { - self.icon.as_ref().map(|icon| - format!(cdn!("/splashes/{}/{}.webp"), self.id, icon)) + self.icon + .as_ref() + .map(|icon| format!(cdn!("/splashes/{}/{}.webp"), self.id, icon)) } /// Starts an integration sync for the given integration Id. @@ -464,9 +446,7 @@ impl PartialGuild { /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html #[inline] - pub fn unban<U: Into<UserId>>(&self, user_id: U) -> Result<()> { - self.id.unban(user_id) - } + pub fn unban<U: Into<UserId>>(&self, user_id: U) -> Result<()> { self.id.unban(user_id) } /// Retrieves the guild's webhooks. /// @@ -474,7 +454,5 @@ impl PartialGuild { /// /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html #[inline] - pub fn webhooks(&self) -> Result<Vec<Webhook>> { - self.id.webhooks() - } + pub fn webhooks(&self) -> Result<Vec<Webhook>> { self.id.webhooks() } } |