diff options
| author | acdenisSK <[email protected]> | 2017-09-30 14:37:41 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-09-30 14:37:41 +0200 |
| commit | 05f158fc89f2adc82e31cf4b93706dc7d25e11d8 (patch) | |
| tree | 0232174006c56c50aa82bfb9dbeac8fac69b5245 /src/framework | |
| parent | Fix User::tag and CurrentUser::tag discrim output (diff) | |
| download | serenity-05f158fc89f2adc82e31cf4b93706dc7d25e11d8.tar.xz serenity-05f158fc89f2adc82e31cf4b93706dc7d25e11d8.zip | |
Fix a few things with the framework trait
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/mod.rs | 30 | ||||
| -rw-r--r-- | src/framework/standard/mod.rs | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 0641ab6..a5f458d 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -67,17 +67,33 @@ use model::Message; use model::UserId; /// 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); + #[doc(hidden)] #[cfg(feature = "standard_framework")] fn update_current_user(&mut self, UserId, bool) {} +} + +impl<F: Framework + ?Sized> Framework for Box<F> { + fn dispatch(&mut self, ctx: Context, msg: Message) { + (**self).dispatch(ctx, msg); + } + + #[cfg(feature = "standard_framework")] + fn update_current_user(&mut self, id: UserId, is_bot: bool) { + (**self).update_current_user(id, is_bot); + } +} + +impl<'a, F: Framework + ?Sized> Framework for &'a mut F { + fn dispatch(&mut self, ctx: Context, msg: Message) { + (**self).dispatch(ctx, msg); + } + #[cfg(feature = "standard_framework")] - fn initialized(&self) -> bool { false } + fn update_current_user(&mut self, id: UserId, is_bot: bool) { + (**self).update_current_user(id, is_bot); + } } + diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs index ffee5d2..feda6a3 100644 --- a/src/framework/standard/mod.rs +++ b/src/framework/standard/mod.rs @@ -958,6 +958,4 @@ impl Framework for StandardFramework { fn update_current_user(&mut self, user_id: UserId, is_bot: bool) { self.user_info = (user_id.0, is_bot); } - - fn initialized(&self) -> bool { self.initialized } } |