valence_server_common/
uuid.rs

1use bevy_ecs::prelude::*;
2use derive_more::Deref;
3use uuid::Uuid;
4
5/// The universally unique identifier of an entity. Component wrapper for a
6/// [`Uuid`].
7///
8/// This component is expected to remain _unique_ and _constant_ during the
9/// lifetime of the entity. The [`Default`] impl generates a new random UUID.
10#[derive(Component, Copy, Clone, PartialEq, Eq, Debug, PartialOrd, Ord, Hash, Deref)]
11pub struct UniqueId(pub Uuid);
12
13/// Generates a new random UUID.
14impl Default for UniqueId {
15    fn default() -> Self {
16        Self(Uuid::from_bytes(rand::random()))
17    }
18}