//! Engine trait and associated types.
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
/// A unique identifier for an Engine.
pub struct EngineId {
id: usize,
}
impl EngineId {
/// Format this identifier as a string.
pub fn id(&self) -> String {
format!("{}", &self.id)
}
}
impl Clone for EngineId {
fn clone(&self) -> Self {
Self::default()
}
}
impl Default for EngineId {
fn default() -> Self {
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
Self { id: NEXT_ID.fetch_add(1, SeqCst) }
}
}