From 2b5578a221babdd624f33171d8bd84e1890fce60 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 12 Jun 2022 16:29:45 -0400 Subject: [PATCH] feat(node): unique identifier --- Cargo.toml | 1 + src/nodes/core.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 54f1b06..2732ea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ glam = {version = "0.20.5", features = ["mint"]} lazy_static = "1.4.0" mint = "0.5.9" mio = {version = "0.8.3", features = ["net", "os-poll", "os-ext"]} +nanoid = "0.4.0" parking_lot = "0.12.1" rccell = "0.1.3" rustc-hash = "1.1.0" diff --git a/src/nodes/core.rs b/src/nodes/core.rs index e8bc8dd..f9f357f 100644 --- a/src/nodes/core.rs +++ b/src/nodes/core.rs @@ -1,4 +1,4 @@ -use super::data::PulseSender; +use super::data::{PulseReceiver, PulseSender}; use super::field::Field; use super::spatial::Spatial; use crate::core::client::Client; @@ -9,12 +9,14 @@ use std::sync::Arc; use std::{collections::HashMap, vec::Vec}; use core::hash::BuildHasherDefault; +use nanoid::nanoid; use rustc_hash::FxHasher; pub type Signal = fn(&Node, Rc, &[u8]) -> Result<()>; pub type Method = fn(&Node, Rc, &[u8]) -> Result>; pub struct Node<'a> { + uid: String, client: Weak>, path: String, // trailing_slash_pos: usize, @@ -46,6 +48,7 @@ impl<'a> Node<'a> { path.push('/'); path.push_str(name); let mut node = Node { + uid: nanoid!(), client, path, // trailing_slash_pos: parent.len(),