aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-07-27 03:16:00 +0200
committeracdenisSK <[email protected]>2017-07-27 03:41:41 +0200
commit7d0c182ce9d8e9ed090eca2f786bbaa34ba33154 (patch)
tree8127b7a8421764515202cb801328b38fbe4ad195 /src/lib.rs
parentFix condional compilation for `Framework::initialized` when builtin-framework... (diff)
downloadserenity-7d0c182ce9d8e9ed090eca2f786bbaa34ba33154.tar.xz
serenity-7d0c182ce9d8e9ed090eca2f786bbaa34ba33154.zip
Make the `framework` module feature-gated and fix the names in the helper macro
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 42767c5..aac04c0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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