mirror of https://github.com/Trivernis/bromine.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
415 B
Rust
18 lines
415 B
Rust
3 years ago
|
use crate::events::event_handler::EventHandler;
|
||
|
use crate::namespace::Namespace;
|
||
|
|
||
|
pub trait NamespaceProvider {
|
||
|
fn name() -> String;
|
||
|
fn register(handler: &mut EventHandler);
|
||
|
}
|
||
|
|
||
|
impl Namespace {
|
||
|
pub fn from_provider<N: NamespaceProvider>() -> Self {
|
||
|
let name = N::name();
|
||
|
let mut handler = EventHandler::new();
|
||
|
N::register(&mut handler);
|
||
|
|
||
|
Self::new(name, handler)
|
||
|
}
|
||
|
}
|