1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::events::event_handler::EventHandler;
use std::sync::Arc;

#[derive(Clone)]
pub struct Namespace {
    name: String,
    pub(crate) handler: Arc<EventHandler>,
}

impl Namespace {
    /// Creates a new namespace with an event handler to register event callbacks on
    pub fn new<S: ToString>(name: S, handler: EventHandler) -> Self {
        Self {
            name: name.to_string(),
            handler: Arc::new(handler),
        }
    }

    pub fn name(&self) -> &String {
        &self.name
    }
}