diff options
| author | acdenisSK <[email protected]> | 2017-07-27 03:16:00 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-27 03:41:41 +0200 |
| commit | 7d0c182ce9d8e9ed090eca2f786bbaa34ba33154 (patch) | |
| tree | 8127b7a8421764515202cb801328b38fbe4ad195 /src | |
| parent | Fix condional compilation for `Framework::initialized` when builtin-framework... (diff) | |
| download | serenity-7d0c182ce9d8e9ed090eca2f786bbaa34ba33154.tar.xz serenity-7d0c182ce9d8e9ed090eca2f786bbaa34ba33154.zip | |
Make the `framework` module feature-gated and fix the names in the helper macro
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/dispatch.rs | 6 | ||||
| -rw-r--r-- | src/client/mod.rs | 6 | ||||
| -rw-r--r-- | src/framework/mod.rs | 16 | ||||
| -rw-r--r-- | src/lib.rs | 23 |
4 files changed, 28 insertions, 23 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 20ed22b..1e81a58 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -12,7 +12,7 @@ use chrono::{Utc, Timelike}; use tokio_core::reactor::Handle; #[cfg(feature="framework")] -use ::ext::framework::Framework; +use ::Framework; #[cfg(feature="cache")] use super::CACHE; @@ -61,12 +61,12 @@ fn context(conn: &Arc<Mutex<Shard>>, Context::new(conn.clone(), data.clone()) } -#[cfg(feature="builtin-framework")] +#[cfg(feature="builtin_framework")] macro_rules! helper { ($enabled:block else $disabled:block) => { $enabled } } -#[cfg(not(feature="builtin-framework"))] +#[cfg(not(feature="builtin_framework"))] macro_rules! helper { ($enabled:block else $disabled:block) => { $disabled } } diff --git a/src/client/mod.rs b/src/client/mod.rs index 07db5b7..a4e5fe5 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -51,8 +51,8 @@ use ::internal::prelude::*; use ::internal::ws_impl::ReceiverExt; use ::model::event::*; -#[cfg(any(feature="framework", feature="builtin_framework"))] -use ::framework::Framework; +#[cfg(feature="framework")] +use ::Framework; static HANDLE_STILL: AtomicBool = ATOMIC_BOOL_INIT; @@ -295,7 +295,7 @@ impl<H: EventHandler + 'static> Client<H> { /// # use serenity::prelude::EventHandler; /// # use std::error::Error; /// # - /// use serenity::framework::Framework; + /// use serenity::Framework; /// use serenity::client::Context; /// use serenity::model::*; /// use tokio_core::reactor::Handle; diff --git a/src/framework/mod.rs b/src/framework/mod.rs index d04f60f..d132b5b 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -84,20 +84,6 @@ use ::client::CACHE; #[cfg(feature="cache")] use ::model::Channel; -/// This trait allows for serenity to either use its builtin framework, or yours. -/// -/// When implementing, be sure to use `tokio_handle.spawn_fn(|| ...; Ok())` when dispatching commands. -/// -/// Note that you may see some other methods in here as well, but they're meant to be internal only for the builtin framework. -pub trait Framework { - fn dispatch(&mut self, Context, Message, &Handle); - - #[cfg(feature="builtin_framework")] - fn update_current_user(&mut self, UserId, bool) {} - #[cfg(feature="builtin_framework")] - fn initialized(&self) -> bool { false } -} - /// A macro to generate "named parameters". This is useful to avoid manually /// using the "arguments" parameter and manually parsing types. /// @@ -837,7 +823,7 @@ impl BuiltinFramework { } } -impl Framework for BuiltinFramework { +impl ::Framework for BuiltinFramework { fn dispatch(&mut self, mut context: Context, message: Message, tokio_handle: &Handle) { let res = command::positions(&mut context, &message, &self.configuration); @@ -142,9 +142,9 @@ pub mod builder; pub mod cache; #[cfg(feature="client")] pub mod client; -#[cfg(any(feature="cache", feature="framework", feature="voice"))] +#[cfg(any(feature="cache", feature="builtin_framework", feature="voice"))] pub mod ext; -#[cfg(feature="framework")] +#[cfg(feature="builtin_framework")] pub mod framework; #[cfg(feature="gateway")] pub mod gateway; @@ -167,6 +167,10 @@ use cache::Cache; #[cfg(feature="cache")] use std::sync::RwLock; +use model::{Message, UserId}; +use client::Context; +use tokio_core::reactor::Handle; + #[cfg(feature="cache")] lazy_static! { /// A mutable and lazily-initialized static binding. It can be accessed @@ -205,3 +209,18 @@ lazy_static! { /// [cache module documentation]: cache/index.html pub static ref CACHE: RwLock<Cache> = RwLock::new(Cache::default()); } + +/// This trait allows for serenity to either use its builtin framework, or yours. +/// +/// When implementing, be sure to use `tokio_handle.spawn_fn(|| ...; Ok())` when dispatching commands. +/// +/// Note that you may see some other methods in here as well, but they're meant to be internal only for the builtin framework. +#[cfg(feature="framework")] +pub trait Framework { + fn dispatch(&mut self, Context, Message, &Handle); + + #[cfg(feature="builtin_framework")] + fn update_current_user(&mut self, UserId, bool) {} + #[cfg(feature="builtin_framework")] + fn initialized(&self) -> bool { false } +}
\ No newline at end of file |