kubi/kubi-shared/src/networking/client.rs

30 lines
653 B
Rust
Raw Normal View History

use shipyard::{Component, Unique, EntityId};
use hashbrown::HashMap;
use nohash_hasher::BuildNoHashHasher;
2023-03-08 20:30:37 -06:00
2023-03-08 10:27:53 -06:00
pub type ClientId = u16;
#[derive(Component, Clone, Debug)]
#[repr(transparent)]
pub struct Username(pub String);
2023-03-08 20:30:37 -06:00
#[derive(Component, Clone, Copy, Debug)]
#[repr(transparent)]
2023-03-08 20:30:37 -06:00
pub struct Client(pub ClientId);
#[derive(Unique)]
#[repr(transparent)]
pub struct ClientIdMap(pub HashMap<ClientId, EntityId, BuildNoHashHasher<ClientId>>);
impl ClientIdMap {
pub fn new() -> Self {
Self(HashMap::with_capacity_and_hasher(16, BuildNoHashHasher::default()))
}
}
impl Default for ClientIdMap {
fn default() -> Self {
Self::new()
}
}