pub struct CommandMetaVarId<T: StateValue + VarValue>(/* private fields */);Expand description
Unique identifier of a command metadata state variable.
This type is very similar to StateId, but T is the value type of the metadata variable.
§Memory
The internal number is a NonZeroU64, that means that
Option<CommandMetaVarId>
and
CommandMetaVarId
are the same size as u64.
§As Hash
The generated internal number has good statistical distribution and can be used as its own hash,
although it is not cryptographically safe, as it is simply a sequential counter scrambled using splitmix64.
§Static
The unique ID cannot be generated at compile time, but you can use the static_id! macro to declare
a lazy static that instantiates the ID.
§Exhaustion Handling
If more IDs are generated them u64::MAX an error is logged, the internal counter is reset and ids are reused.
Implementations§
Source§impl<T: StateValue + VarValue> CommandMetaVarId<T>
impl<T: StateValue + VarValue> CommandMetaVarId<T>
Sourcepub fn new_unique() -> Self
pub fn new_unique() -> Self
Generates a new unique ID.
Sourcepub fn sequential(self) -> u64
pub fn sequential(self) -> u64
Un-scramble the underlying value to get the original sequential count number.
If two IDs, id0 and id1 where generated by the same thread then id0.sequential() < id1.sequential().
Sourcepub fn from_raw(raw: u64) -> Self
pub fn from_raw(raw: u64) -> Self
Creates an ID from a raw value.
The value must not be zero, panics if it is, the value must have been provided by get otherwise
the ID will not be unique.
Sourcepub fn from_sequential(num: u64) -> Self
pub fn from_sequential(num: u64) -> Self
Creates an ID from a sequential number.
§Safety
The value must not be zero, panics if it is, the value must have been provided by sequential otherwise
the ID will not be unique.
Trait Implementations§
Source§impl<T: StateValue + VarValue> Clone for CommandMetaVarId<T>
impl<T: StateValue + VarValue> Clone for CommandMetaVarId<T>
Source§impl<T: StateValue + VarValue> Debug for CommandMetaVarId<T>
impl<T: StateValue + VarValue> Debug for CommandMetaVarId<T>
Source§impl<T: StateValue + VarValue> Hash for CommandMetaVarId<T>
impl<T: StateValue + VarValue> Hash for CommandMetaVarId<T>
Source§impl<T: StateValue + VarValue> PartialEq for CommandMetaVarId<T>
impl<T: StateValue + VarValue> PartialEq for CommandMetaVarId<T>
Source§impl<T: StateValue + VarValue> UniqueId for CommandMetaVarId<T>
impl<T: StateValue + VarValue> UniqueId for CommandMetaVarId<T>
Source§fn new_unique() -> Self
fn new_unique() -> Self
impl<T: StateValue + VarValue> Copy for CommandMetaVarId<T>
impl<T: StateValue + VarValue> Eq for CommandMetaVarId<T>
impl<T: StateValue + VarValue> NoUninit for CommandMetaVarId<T>
impl<T: StateValue + VarValue> PodInOption for CommandMetaVarId<T>
impl<T: StateValue + VarValue> ZeroableInOption for CommandMetaVarId<T>
Auto Trait Implementations§
impl<T> Freeze for CommandMetaVarId<T>
impl<T> RefUnwindSafe for CommandMetaVarId<T>where
T: RefUnwindSafe,
impl<T> Send for CommandMetaVarId<T>
impl<T> Sync for CommandMetaVarId<T>
impl<T> Unpin for CommandMetaVarId<T>where
T: Unpin,
impl<T> UnwindSafe for CommandMetaVarId<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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>
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>
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