pub struct NetworkIdAllocator { /* private fields */ }Expand description
Authoritative allocator for NetworkIds.
Used by the server to ensure IDs are unique and monotonically increasing. Thread-safe and lock-free.
Implementations§
Source§impl NetworkIdAllocator
impl NetworkIdAllocator
Sourcepub fn new(start_id: u64) -> Self
pub fn new(start_id: u64) -> Self
Creates a new allocator starting from a specific ID. Must be at least MIN_DYNAMIC_NETWORK_ID.
Sourcepub fn allocate(&self) -> Result<NetworkId, AllocatorError>
pub fn allocate(&self) -> Result<NetworkId, AllocatorError>
Allocates a new unique NetworkId.
§Errors
Returns AllocatorError::Overflow if the next ID would exceed u64::MAX.
Trait Implementations§
Source§impl Debug for NetworkIdAllocator
impl Debug for NetworkIdAllocator
Auto Trait Implementations§
impl !Freeze for NetworkIdAllocator
impl RefUnwindSafe for NetworkIdAllocator
impl Send for NetworkIdAllocator
impl Sync for NetworkIdAllocator
impl Unpin for NetworkIdAllocator
impl UnsafeUnpin for NetworkIdAllocator
impl UnwindSafe for NetworkIdAllocator
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