#[repr(C)]pub struct NodeId {
pub high: u64,
pub low: u64,
}Expand description
A 128-bit node identifier generated from XorShiftRng.
NodeIds uniquely identify clients and nodes in the network. They are formatted as UUID-style strings for human readability and protocol compatibility.
Fields§
§high: u64§low: u64Implementations§
Source§impl NodeId
impl NodeId
Sourcepub fn generate(rng: &mut XorShiftRng) -> Self
pub fn generate(rng: &mut XorShiftRng) -> Self
Generate a new random NodeId using XorShiftRng.
§Example
use bbx_core::random::XorShiftRng;
use bbx_net::address::NodeId;
let mut rng = XorShiftRng::new(12345);
let node_id = NodeId::generate(&mut rng);Sourcepub fn generate_with_entropy(clock_micros: u64) -> Self
pub fn generate_with_entropy(clock_micros: u64) -> Self
Generate a NodeId with mixed entropy sources for improved unpredictability.
Combines multiple entropy sources: time, process ID, memory address (ASLR), and a monotonic counter to create a more unpredictable seed.
Sourcepub fn generate_unique<F>(clock_micros: u64, exists: F) -> Self
pub fn generate_unique<F>(clock_micros: u64, exists: F) -> Self
Generate a unique NodeId that doesn’t collide with existing IDs.
Uses generate_with_entropy internally and loops until finding an ID
that the exists predicate returns false for.
Sourcepub const fn from_parts(high: u64, low: u64) -> Self
pub const fn from_parts(high: u64, low: u64) -> Self
Create a NodeId from explicit high and low parts.
Sourcepub fn to_uuid_string(&self) -> String
pub fn to_uuid_string(&self) -> String
Format as hyphenated UUID string.
Returns a string in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
Sourcepub fn from_uuid_string(s: &str) -> Result<Self>
pub fn from_uuid_string(s: &str) -> Result<Self>
Parse from UUID string.
Accepts the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.