1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use core::hash::{Hash, Hasher};

use nohash_hasher::IsEnabled;
use rand::{rngs::SmallRng, RngCore, SeedableRng};

#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct EntityId(u64);

impl Hash for EntityId {
    fn hash<H: Hasher>(&self, state: &mut H) {
        state.write_u64(self.0);
    }
}

impl IsEnabled for EntityId {}

impl EntityId {
    pub fn random() -> Self {
        let mut rng = SmallRng::from_entropy();
        Self(rng.next_u64())
    }
}