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)Trait Implementations§
Source§impl<'de> Deserialize<'de> for UID
impl<'de> Deserialize<'de> for UID
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for UID
impl Eq for UID
impl StructuralPartialEq for UID
Auto Trait Implementations§
impl Freeze for UID
impl RefUnwindSafe for UID
impl Send for UID
impl Sync for UID
impl Unpin for UID
impl UnwindSafe for UID
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)