aboutsummaryrefslogtreecommitdiff
path: root/src/utils/mod.rs
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-15 11:36:53 -0800
committerAustin Hellyer <[email protected]>2016-11-15 11:36:53 -0800
commit5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4 (patch)
tree7cf531e4790109d6d7edd26bc5b483378d5ba5ac /src/utils/mod.rs
parentEmbed Author: everything but 'name' is optional (diff)
downloadserenity-5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4.tar.xz
serenity-5ccfaaa3b1a030b1fd0dcd364bdae001347d36e4.zip
Add state/framework/etc. conditional compile flags
This adds conditional compilation for the following features, in addition to the voice conditional compilation flag: - extras (message builder) - framework - methods - state These 4 are enabled _by default_, while the `voice` feature flag is disabled. Disabling the state will allow incredibly low-memory bots.
Diffstat (limited to 'src/utils/mod.rs')
-rw-r--r--src/utils/mod.rs90
1 files changed, 11 insertions, 79 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 28d18f1..ccf7787 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -1,8 +1,18 @@
//! A set of utilities to help with common use cases that are not required to
//! fully use the library.
+#[macro_use]
+pub mod macros;
+
pub mod builder;
+mod colour;
+
+#[cfg(feature = "extras")]
+mod message_builder;
+
+pub use self::colour::Colour;
+
use base64;
use std::ffi::OsStr;
use std::fs::File;
@@ -10,10 +20,7 @@ use std::io::Read;
use std::path::Path;
use ::internal::prelude::*;
-mod colour;
-mod message_builder;
-
-pub use self::colour::Colour;
+#[cfg(feature = "extras")]
pub use self::message_builder::MessageBuilder;
macro_rules! cdn_concat {
@@ -83,81 +90,6 @@ pub fn into_array(value: Value) -> Result<Vec<Value>> {
}
}
-macro_rules! request {
- ($route:expr, $method:ident($body:expr), $url:expr, $($rest:tt)*) => {{
- let client = HyperClient::new();
- try!(request($route, || client
- .$method(&format!(api!($url), $($rest)*))
- .body(&$body)))
- }};
- ($route:expr, $method:ident($body:expr), $url:expr) => {{
- let client = HyperClient::new();
- try!(request($route, || client
- .$method(api!($url))
- .body(&$body)))
- }};
- ($route:expr, $method:ident, $url:expr, $($rest:tt)*) => {{
- let client = HyperClient::new();
- try!(request($route, || client
- .$method(&format!(api!($url), $($rest)*))))
- }};
- ($route:expr, $method:ident, $url:expr) => {{
- let client = HyperClient::new();
- try!(request($route, || client
- .$method(api_concat!($url))))
- }};
-}
-
-// Enable/disable check for voice
-macro_rules! feature_voice {
- ($enabled:block) => {
- {
- feature_voice_enabled! {{
- $enabled
- }}
- }
- };
- ($enabled:block $disabled:block) => {
- {
- feature_voice_enabled! {{
- $enabled
- }}
-
- feature_voice_disabled! {{
- $disabled
- }}
- }
- };
-}
-
-#[cfg(feature="voice")]
-macro_rules! feature_voice_enabled {
- ($enabled:block) => {
- {
- $enabled
- }
- }
-}
-
-#[cfg(not(feature="voice"))]
-macro_rules! feature_voice_enabled {
- ($enabled:block) => {}
-}
-
-#[cfg(feature="voice")]
-macro_rules! feature_voice_disabled {
- ($disabled:block) => {}
-}
-
-#[cfg(not(feature="voice"))]
-macro_rules! feature_voice_disabled {
- ($disabled:block) => {
- {
- $disabled
- }
- }
-}
-
/// Retrieves the "code" part of an [invite][`RichInvite`] out of a URL.
///
/// # Examples