add plugin infrastructure

This commit is contained in:
lumi 2017-02-20 16:28:51 +01:00
commit 83fdd9866c
9 changed files with 401 additions and 2 deletions

25
src/event.rs Normal file
View file

@ -0,0 +1,25 @@
use std::fmt::Debug;
use std::any::Any;
pub struct AbstractEvent {
inner: Box<Any>,
}
impl AbstractEvent {
pub fn new<E: Event>(event: E) -> AbstractEvent {
AbstractEvent {
inner: Box::new(event),
}
}
pub fn downcast<E: Event + 'static>(&self) -> Option<&E> {
self.inner.downcast_ref::<E>()
}
pub fn is<E: Event + 'static>(&self) -> bool {
self.inner.is::<E>()
}
}
pub trait Event: Any + Debug {}