feat(spatial): basic interface

This commit is contained in:
Nova
2022-06-05 05:04:16 -04:00
parent fedbe17b7a
commit 1d93046d5e
4 changed files with 74 additions and 19 deletions

View File

@@ -29,23 +29,24 @@ impl<'a> Node<'a> {
self.path.as_str()
}
pub fn from_path(
pub fn create(
client: WeakCell<Client<'a>>,
path: &str,
parent: &str,
name: &str,
destroyable: bool,
) -> Result<Node<'a>> {
ensure!(path.starts_with('/'), "Invalid path {}", path);
Ok(Node {
) -> Self {
let mut path = parent.to_string();
path.push('/');
path.push_str(name);
Node {
client,
path: path.to_string(),
trailing_slash_pos: path
.rfind('/')
.ok_or_else(|| anyhow!("Invalid path {}", path))?,
path: path,
trailing_slash_pos: parent.len(),
local_signals: HashMap::new(),
local_methods: HashMap::new(),
destroyable,
spatial: None,
})
}
}
pub fn add_local_signal(&mut self, method: &str, signal: Signal<'a>) {