use std::collections::HashMap;
use crate::systems::DynSystem;
pub struct Scope {
children: HashMap<String, Scope>,
systems: Vec<DynSystem>,
}
impl Scope {
pub fn new(systems: Vec<DynSystem>) -> Self {
Self {
children: HashMap::new(),
systems,
}
}
pub fn empty() -> Self {
Scope::new(vec![])
}
pub fn route(mut self, path: impl Into<String>, route: impl Into<Scope>) -> Self {
self.children.insert(path.into(), route.into());
self
}
pub fn systems(&self) -> &[DynSystem] {
&self.systems
}
pub fn get_child<'a>(&'a self, path: &str) -> Option<&'a Scope> {
self.children.get(path)
}
}
impl From<Vec<DynSystem>> for Scope {
fn from(value: Vec<DynSystem>) -> Self {
Scope::new(value)
}
}