diff options
| author | Austin Hellyer <[email protected]> | 2016-11-29 20:51:10 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-29 22:27:59 -0800 |
| commit | 93b990d8d1bc9df69b8e27a3db61da570822aad6 (patch) | |
| tree | 6305cf635df90681527a8e736f65ff19f21fd8bc /src/utils | |
| parent | Add more shiny readme badges (diff) | |
| download | serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.tar.xz serenity-93b990d8d1bc9df69b8e27a3db61da570822aad6.zip | |
Clean up the codebase
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/builder/create_embed.rs | 36 | ||||
| -rw-r--r-- | src/utils/builder/mod.rs | 1 | ||||
| -rw-r--r-- | src/utils/macros.rs | 11 | ||||
| -rw-r--r-- | src/utils/mod.rs | 54 |
4 files changed, 3 insertions, 99 deletions
diff --git a/src/utils/builder/create_embed.rs b/src/utils/builder/create_embed.rs index 0b0322c..369784f 100644 --- a/src/utils/builder/create_embed.rs +++ b/src/utils/builder/create_embed.rs @@ -349,39 +349,3 @@ impl Default for CreateEmbedThumbnail { CreateEmbedThumbnail(ObjectBuilder::new()) } } - -/// A builder to create a fake [`Embed`] object's video, for use with the -/// [`CreateEmbed::video`] method. -/// -/// Requires that you specify a [`url`]. -/// -/// [`Embed`]: ../../model/struct.Embed.html -/// [`CreateEmbed::video`]: struct.CreateEmbed.html#method.video -/// [`url`]: #method.url -pub struct CreateEmbedVideo(pub ObjectBuilder); - -impl CreateEmbedVideo { - /// Set the height of the video, in pixels. - pub fn height(self, height: u64) -> Self { - CreateEmbedVideo(self.0.insert("height", height)) - } - - /// Set the source URL of the video. - /// - /// _Must_ be specified. - pub fn url(self, url: &str) -> Self { - CreateEmbedVideo(self.0.insert("url", url)) - } - - /// Set the width of the video, in pixels. - pub fn width(self, width: &str) -> Self { - CreateEmbedVideo(self.0.insert("width", width)) - } -} - -impl Default for CreateEmbedVideo { - /// Creates a builder with no default values. - fn default() -> CreateEmbedVideo { - CreateEmbedVideo(ObjectBuilder::new()) - } -} diff --git a/src/utils/builder/mod.rs b/src/utils/builder/mod.rs index bc8a20d..497d309 100644 --- a/src/utils/builder/mod.rs +++ b/src/utils/builder/mod.rs @@ -23,7 +23,6 @@ pub use self::create_embed::{ CreateEmbedField, CreateEmbedImage, CreateEmbedThumbnail, - CreateEmbedVideo, }; pub use self::create_invite::CreateInvite; pub use self::create_message::CreateMessage; diff --git a/src/utils/macros.rs b/src/utils/macros.rs index d9026af..e8f74dd 100644 --- a/src/utils/macros.rs +++ b/src/utils/macros.rs @@ -19,11 +19,11 @@ macro_rules! request { ($route:expr, $method:ident, $url:expr) => {{ let client = HyperClient::new(); try!(request($route, || client - .$method(api_concat!($url)))) + .$method(api!($url)))) }}; } -macro_rules! cdn_concat { +macro_rules! cdn { ($e:expr) => { concat!("https://cdn.discordapp.com", $e) } @@ -37,12 +37,7 @@ macro_rules! api { }; } -macro_rules! api_concat { - ($e:expr) => { - concat!("https://discordapp.com/api/v6", $e) - } -} -macro_rules! status_concat { +macro_rules! status { ($e:expr) => { concat!("https://status.discordapp.com/api/v2", $e) } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 0c154dd..aa97f4a 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -21,60 +21,6 @@ use ::internal::prelude::*; pub use self::message_builder::MessageBuilder; -macro_rules! cdn_concat { - ($e:expr) => { - concat!("https://cdn.discordapp.com", $e) - } -} -macro_rules! api { - ($e:expr) => { - concat!("https://discordapp.com/api/v6", $e) - }; - ($e:expr, $($rest:tt)*) => { - format!(api!($e), $($rest)*) - }; -} - -macro_rules! api_concat { - ($e:expr) => { - concat!("https://discordapp.com/api/v6", $e) - } -} -macro_rules! status_concat { - ($e:expr) => { - concat!("https://status.discordapp.com/api/v2", $e) - } -} - -macro_rules! map_nums { - ($item:ident; $($entry:ident $value:expr,)*) => { - impl $item { - #[allow(dead_code)] - pub fn num(&self) -> u64 { - match *self { - $($item::$entry => $value,)* - } - } - - #[allow(dead_code)] - pub fn from_num(num: u64) -> Option<Self> { - match num { - $($value => Some($item::$entry),)* - _ => None, - } - } - - #[allow(dead_code)] - fn decode(value: Value) -> Result<Self> { - value.as_u64().and_then(Self::from_num).ok_or(Error::Decode( - concat!("Expected valid ", stringify!($item)), - value - )) - } - } - } -} - #[doc(hidden)] pub fn decode_array<T, F: Fn(Value) -> Result<T>>(value: Value, f: F) -> Result<Vec<T>> { into_array(value).and_then(|x| x.into_iter().map(f).collect()) |