pub struct StatTypeEntry {
pub key: Identifier,
registry: LazyLock<StatValueRegistryData, Box<dyn FnOnce() -> StatValueRegistryData + Send + Sync>>,
}Expand description
An entry stored in the stat type registry. It represents a stat type.
A stat type is always associated with a registry whose values will be used to identify
stats from this stat type. Therefore, StatTypeEntry contains the registry responsible for the
encoding and decoding of the values involved.
For example, ITEM_DROPPED uses the item registry to have each item in this registry become a stat
under this stat type (like diamond) to track how many of those items have been dropped by the player.
Internally, the registry is stored in a LazyLock, so that the reference
to the registry is only loaded after it has initialized.
Fields§
§key: IdentifierThe identifier of this stat type.
registry: LazyLock<StatValueRegistryData, Box<dyn FnOnce() -> StatValueRegistryData + Send + Sync>>The registry that can encode and decode the stat identity involved in this stat type.
Implementations§
Source§impl StatTypeEntry
impl StatTypeEntry
Sourcepub fn registry_len(&self) -> usize
pub fn registry_len(&self) -> usize
Gets the number of entries in this registry that this stat type is associated with.
Sourcepub fn key_from_id(&self, id: usize) -> Option<&Identifier>
pub fn key_from_id(&self, id: usize) -> Option<&Identifier>
Gets the key of an item in this registry by its registry ID.
Sourcepub fn id_from_key(&self, key: &Identifier) -> Option<usize>
pub fn id_from_key(&self, key: &Identifier) -> Option<usize>
Gets the registry ID of an item in this registry by its key.
Sourcepub fn value_from_id(
&self,
id: usize,
) -> Option<&'static dyn StatValueRegistryEntry>
pub fn value_from_id( &self, id: usize, ) -> Option<&'static dyn StatValueRegistryEntry>
Gets the erased value of an item in this registry by its registry ID.
Sourcepub fn value_from_key(
&self,
key: &Identifier,
) -> Option<&'static dyn StatValueRegistryEntry>
pub fn value_from_key( &self, key: &Identifier, ) -> Option<&'static dyn StatValueRegistryEntry>
Gets the erased value of an item in this registry by its key.
Trait Implementations§
Source§impl Debug for StatTypeEntry
impl Debug for StatTypeEntry
impl Eq for StatTypeEntry
Source§impl PartialEq for StatTypeEntry
impl PartialEq for StatTypeEntry
Auto Trait Implementations§
impl !Freeze for StatTypeEntry
impl !RefUnwindSafe for StatTypeEntry
impl !UnwindSafe for StatTypeEntry
impl Send for StatTypeEntry
impl Sync for StatTypeEntry
impl Unpin for StatTypeEntry
impl UnsafeUnpin for StatTypeEntry
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
§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> ⓘ
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 moreArc<SyncMutex<>>