feat(node): unique identifier
This commit is contained in:
@@ -15,6 +15,7 @@ glam = {version = "0.20.5", features = ["mint"]}
|
|||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
mint = "0.5.9"
|
mint = "0.5.9"
|
||||||
mio = {version = "0.8.3", features = ["net", "os-poll", "os-ext"]}
|
mio = {version = "0.8.3", features = ["net", "os-poll", "os-ext"]}
|
||||||
|
nanoid = "0.4.0"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
rccell = "0.1.3"
|
rccell = "0.1.3"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use super::data::PulseSender;
|
use super::data::{PulseReceiver, PulseSender};
|
||||||
use super::field::Field;
|
use super::field::Field;
|
||||||
use super::spatial::Spatial;
|
use super::spatial::Spatial;
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
@@ -9,12 +9,14 @@ use std::sync::Arc;
|
|||||||
use std::{collections::HashMap, vec::Vec};
|
use std::{collections::HashMap, vec::Vec};
|
||||||
|
|
||||||
use core::hash::BuildHasherDefault;
|
use core::hash::BuildHasherDefault;
|
||||||
|
use nanoid::nanoid;
|
||||||
use rustc_hash::FxHasher;
|
use rustc_hash::FxHasher;
|
||||||
|
|
||||||
pub type Signal = fn(&Node, Rc<Client>, &[u8]) -> Result<()>;
|
pub type Signal = fn(&Node, Rc<Client>, &[u8]) -> Result<()>;
|
||||||
pub type Method = fn(&Node, Rc<Client>, &[u8]) -> Result<Vec<u8>>;
|
pub type Method = fn(&Node, Rc<Client>, &[u8]) -> Result<Vec<u8>>;
|
||||||
|
|
||||||
pub struct Node<'a> {
|
pub struct Node<'a> {
|
||||||
|
uid: String,
|
||||||
client: Weak<Client<'a>>,
|
client: Weak<Client<'a>>,
|
||||||
path: String,
|
path: String,
|
||||||
// trailing_slash_pos: usize,
|
// trailing_slash_pos: usize,
|
||||||
@@ -46,6 +48,7 @@ impl<'a> Node<'a> {
|
|||||||
path.push('/');
|
path.push('/');
|
||||||
path.push_str(name);
|
path.push_str(name);
|
||||||
let mut node = Node {
|
let mut node = Node {
|
||||||
|
uid: nanoid!(),
|
||||||
client,
|
client,
|
||||||
path,
|
path,
|
||||||
// trailing_slash_pos: parent.len(),
|
// trailing_slash_pos: parent.len(),
|
||||||
|
|||||||
Reference in New Issue
Block a user