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.
bromine/src/namespaces/provider_trait.rs

18 lines
415 B
Rust

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)
}
}