use std::any::TypeId;
use crate::{Registry, RegistryId};
#[derive(Copy, Clone, Debug, Eq)]
pub struct RegistryInfo {
id: RegistryId,
type_id: fn() -> TypeId,
name: fn() -> &'static str
}
impl RegistryInfo {
pub const fn of<R: Registry + ?Sized>() -> Self {
Self {
id: RegistryId::of::<R>(),
type_id: TypeId::of::<R>,
name: R::name
}
}
pub const fn id(&self) -> RegistryId {
self.id
}
pub fn type_id(&self) -> TypeId {
(self.type_id)()
}
pub fn name(&self) -> &'static str {
(self.name)()
}
}
impl PartialEq for RegistryInfo {
fn eq(&self, other: &Self) -> bool {
self.type_id() == other.type_id()
}
}