//! Stable entity identity shared by storage and transaction tracking.
use std::fmt;
/// Unique identifier for any entity in the unified storage
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EntityId(pub u64);
impl EntityId {
/// Create a new entity ID
pub fn new(id: u64) -> Self {
Self(id)
}
/// Get the raw ID value
pub fn raw(&self) -> u64 {
self.0
}
}
impl fmt::Display for EntityId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "e{}", self.0)
}
}
impl From<u64> for EntityId {
fn from(id: u64) -> Self {
Self(id)
}
}