aboutsummaryrefslogtreecommitdiff
path: root/src/model/id.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/model/id.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/model/id.rs')
-rw-r--r--src/model/id.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/model/id.rs b/src/model/id.rs
index 0d9fb32..ff236e1 100644
--- a/src/model/id.rs
+++ b/src/model/id.rs
@@ -1,15 +1,20 @@
use super::*;
+
+#[cfg(feature = "methods")]
use ::client::{STATE, http};
+#[cfg(feature = "methods")]
use ::internal::prelude::*;
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)
}
/// 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);
@@ -34,6 +39,7 @@ impl ChannelId {
/// **Note**: Requires the [Manage Webhooks] permission.
///
/// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html
+ #[cfg(feature="methods")]
pub fn webhooks(&self) -> Result<Vec<Webhook>> {
http::get_channel_webhooks(self.0)
}
@@ -69,6 +75,7 @@ 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()
}
@@ -77,6 +84,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> {
http::get_guild(self.0)
}
@@ -96,6 +104,7 @@ impl GuildId {
/// **Note**: Requires the [Manage Webhooks] permission.
///
/// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html
+ #[cfg(feature="methods")]
pub fn webhooks(&self) -> Result<Vec<Webhook>> {
http::get_guild_webhooks(self.0)
}
@@ -145,6 +154,7 @@ impl From<Role> for RoleId {
impl RoleId {
/// Search the state for the role.
+ #[cfg(feature="methods")]
pub fn find(&self) -> Option<Role> {
STATE.lock()
.unwrap()
@@ -206,6 +216,7 @@ impl WebhookId {
/// **Note**: Requires the [Manage Webhooks] permission.
///
/// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html
+ #[cfg(feature="methods")]
pub fn webhooks(&self) -> Result<Webhook> {
http::get_webhook(self.0)
}