pub struct IdAllocator { /* private fields */ }
Expand description
An unique ID allocator that allows management of IDs in a given interval.
Implementations§
Source§impl IdAllocator
impl IdAllocator
Sourcepub fn new(range_base: u32, range_end: u32) -> Result<Self>
pub fn new(range_base: u32, range_end: u32) -> Result<Self>
Creates a new instance of IdAllocator that will be used to manage the
allocation and release of ids from the interval specified by
range_base
and range_end
Sourcepub fn allocate_id(&mut self) -> Result<u32>
pub fn allocate_id(&mut self) -> Result<u32>
Allocate an ID from the managed range. We first try to reuse one of the IDs released before. If there is no ID to reuse we return the next available one from the managed range.
Trait Implementations§
Source§impl Clone for IdAllocator
impl Clone for IdAllocator
Source§fn clone(&self) -> IdAllocator
fn clone(&self) -> IdAllocator
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for IdAllocator
impl RefUnwindSafe for IdAllocator
impl Send for IdAllocator
impl Sync for IdAllocator
impl Unpin for IdAllocator
impl UnwindSafe for IdAllocator
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