pub struct WorkerId(/* private fields */);Expand description
Deterministic 64-bit worker identifier derived from InstanceId.
WorkerId enables embedding instance identity into fixed-size handles that can be
passed with value semantics. A u128 is the largest integer that can be passed
by value, making it ideal for handles that encode both routing and event information.
WorkerId is used in:
EventHandle(velo): Uses 64 bits for WorkerId + 64 bits for event detailsEventRoutingTable(velo): Maps worker_id → instance_id for event routing- Discovery systems: Lookup key for peer information
WorkerId is always derived from InstanceId using xxh3_64 hash. This ensures consistency across the system without needing to store both values.
§Example
ⓘ
use velo_common::{InstanceId, WorkerId};
let instance_id = get_instance_id(); // From ActiveMessageClient
let worker_id = instance_id.worker_id();
// WorkerId is deterministic
assert_eq!(worker_id, instance_id.worker_id());Implementations§
Trait Implementations§
impl Copy for WorkerId
Source§impl<'de> Deserialize<'de> for WorkerId
impl<'de> Deserialize<'de> for WorkerId
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for WorkerId
Source§impl From<&InstanceId> for WorkerId
impl From<&InstanceId> for WorkerId
Source§fn from(id: &InstanceId) -> Self
fn from(id: &InstanceId) -> Self
Derive WorkerId from InstanceId using xxh3_64 hash.
This is the canonical way to compute WorkerId - it should never be constructed any other way to ensure consistency.
Source§impl From<InstanceId> for WorkerId
impl From<InstanceId> for WorkerId
Source§fn from(id: InstanceId) -> Self
fn from(id: InstanceId) -> Self
Converts to this type from the input type.
Source§impl Ord for WorkerId
impl Ord for WorkerId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for WorkerId
impl PartialOrd for WorkerId
impl StructuralPartialEq for WorkerId
Auto Trait Implementations§
impl Freeze for WorkerId
impl RefUnwindSafe for WorkerId
impl Send for WorkerId
impl Sync for WorkerId
impl Unpin for WorkerId
impl UnsafeUnpin for WorkerId
impl UnwindSafe for WorkerId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more