add plugin infrastructure
This commit is contained in:
parent
8883f343b7
commit
83fdd9866c
9 changed files with 401 additions and 2 deletions
25
src/event.rs
Normal file
25
src/event.rs
Normal 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 {}
|
||||
Loading…
Reference in a new issue