pub struct IdFactoryWithReuse<T> { /* private fields */ }
Expand description
An IdFactory
, but extended with a free list to allow for id reuse for ids such as
BackendJobId
.
If silent untracked re-use of ids is okay, consider using the cheaper
IdFactory::wrapping_get
method.
Implementations§
Source§impl<T> IdFactoryWithReuse<T>
impl<T> IdFactoryWithReuse<T>
Sourcepub const fn new_const(start: NonZeroU64, max: NonZeroU64) -> Self
pub const fn new_const(start: NonZeroU64, max: NonZeroU64) -> Self
Create a factory for ids in the range start..=max
. Provides a less convenient API than
IdFactoryWithReuse::new
, but skips a type conversion that would make the function
non-const.
Source§impl<T> IdFactoryWithReuse<T>where
T: TryFrom<NonZeroU64>,
impl<T> IdFactoryWithReuse<T>where
T: TryFrom<NonZeroU64>,
Sourcepub unsafe fn reuse(&self, id: T)
pub unsafe fn reuse(&self, id: T)
Add an id to the free list, allowing it to be re-used on a subsequent call to
IdFactoryWithReuse::get
.
§Safety
The id must no longer be used. Must be a valid id that was previously returned by
IdFactoryWithReuse::get
.
Auto Trait Implementations§
impl<T> !Freeze for IdFactoryWithReuse<T>
impl<T> RefUnwindSafe for IdFactoryWithReuse<T>where
T: RefUnwindSafe,
impl<T> Send for IdFactoryWithReuse<T>where
T: Send,
impl<T> Sync for IdFactoryWithReuse<T>
impl<T> Unpin for IdFactoryWithReuse<T>where
T: Unpin,
impl<T> UnwindSafe for IdFactoryWithReuse<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: Any,
impl<T> Any for Twhere
T: Any,
fn get_type_id(&self) -> TypeId
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more