pub struct PlayerRegistry<Player: PlayerInfo> { /* private fields */ }Expand description
A registry for managing players by both their UUID and NFC UID.
The registry ensures that updates to players’ NFC UIDs automatically keep internal lookup maps in sync.
Implementations§
Source§impl<Player: PlayerInfo> PlayerRegistry<Player>
impl<Player: PlayerInfo> PlayerRegistry<Player>
Sourcepub fn new(players: Vec<Player>) -> Self
pub fn new(players: Vec<Player>) -> Self
Creates a new PlayerRegistry from a list of players
Sourcepub fn get_by_id(&self, id: Uuid) -> Option<Arc<RwLock<Player>>>
pub fn get_by_id(&self, id: Uuid) -> Option<Arc<RwLock<Player>>>
Returns the shared player reference (Arc) by their UUID.
Use Self::read_by_id() if you only need read access.
Sourcepub fn get_by_nfc_uid(&self, nfc_uid: NfcUid) -> Option<Arc<RwLock<Player>>>
pub fn get_by_nfc_uid(&self, nfc_uid: NfcUid) -> Option<Arc<RwLock<Player>>>
Returns the shared player reference (Arc) by their NFC UID.
/// Use Self::read_by_nfc_uid() if you only need read access.
Sourcepub fn read_by_id(&self, id: Uuid) -> Option<RwLockReadGuard<'_, Player>>
pub fn read_by_id(&self, id: Uuid) -> Option<RwLockReadGuard<'_, Player>>
Returns a read-only lock on a player by their UUID.
Returns None if no player with the given ID exists.
Sourcepub fn read_by_nfc_uid(
&self,
nfc_uid: NfcUid,
) -> Option<RwLockReadGuard<'_, Player>>
pub fn read_by_nfc_uid( &self, nfc_uid: NfcUid, ) -> Option<RwLockReadGuard<'_, Player>>
Returns a read-only lock on a player by their NFC UID.
Returns None if no player with the given NFC UID exists.
Sourcepub fn contains_id(&self, id: Uuid) -> bool
pub fn contains_id(&self, id: Uuid) -> bool
Returns true if a player with the given UUID exists in the registry.
Sourcepub fn mutate_by_id<F>(&mut self, id: Uuid, mutator: F)where
F: FnOnce(&mut Player),
pub fn mutate_by_id<F>(&mut self, id: Uuid, mutator: F)where
F: FnOnce(&mut Player),
Mutates a player by their UUID.
Automatically updates the internal NFC UID lookup map if the player’s NFC UID changes.
If no player with the given ID exists, this method does nothing.
Trait Implementations§
Source§impl<Player: Debug + PlayerInfo> Debug for PlayerRegistry<Player>
impl<Player: Debug + PlayerInfo> Debug for PlayerRegistry<Player>
Source§impl<Player: PlayerInfo> From<Vec<Player>> for PlayerRegistry<Player>
impl<Player: PlayerInfo> From<Vec<Player>> for PlayerRegistry<Player>
Auto Trait Implementations§
impl<Player> Freeze for PlayerRegistry<Player>
impl<Player> RefUnwindSafe for PlayerRegistry<Player>
impl<Player> Send for PlayerRegistry<Player>
impl<Player> Sync for PlayerRegistry<Player>
impl<Player> Unpin for PlayerRegistry<Player>
impl<Player> UnsafeUnpin for PlayerRegistry<Player>
impl<Player> UnwindSafe for PlayerRegistry<Player>
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
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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