pub struct UID {
pub first: u64,
pub second: u64,
}Expand description
128-bit unique identifier (FDB-compatible).
FDB pattern: well-known UIDs use first = u64::MAX (equivalent to -1 in C++).
Random UIDs have both parts randomly generated.
§Examples
use moonpool_core::UID;
// Create a well-known UID for system services
let ping_token = UID::well_known(1);
assert!(ping_token.is_well_known());
// Create a regular UID
let uid = UID::new(0x123, 0x456);
assert!(!uid.is_well_known());Fields§
§first: u64First 64 bits. For well-known UIDs, this is u64::MAX.
second: u64Second 64 bits. For well-known UIDs, this is the token ID.
Implementations§
Source§impl UID
impl UID
Sourcepub const fn well_known(token_id: u32) -> Self
pub const fn well_known(token_id: u32) -> Self
Create a well-known UID (FDB pattern: first = -1).
Well-known UIDs are used for system services that need deterministic addressing without discovery (e.g., Ping, EndpointNotFound).
Sourcepub const fn is_well_known(&self) -> bool
pub const fn is_well_known(&self) -> bool
Check if this is a well-known UID.
Well-known UIDs have first == u64::MAX, allowing O(1) lookup
in the endpoint map via array indexing.
Sourcepub const fn adjusted(&self, index: u32) -> Self
pub const fn adjusted(&self, index: u32) -> Self
Create adjusted UID for interface serialization (FDB pattern).
Used to derive multiple endpoints from a single base token. This allows serializing only one endpoint for an interface, with others derived using this method.
§FDB Implementation
From FlowTransport.h:
UID(token.first() + (uint64_t(index) << 32),
(token.second() & 0xffffffff00000000LL) | newIndex)