type_registry/raw/
registry_id.rs1use std::hash::{Hash, Hasher};
2use crate::logical::Registry;
3use crate::raw::RegistryInfo;
4
5#[derive(Copy, Clone, Debug, Eq)]
7pub struct RegistryId {
8 get_registry_info: fn() -> RegistryInfo
12}
13
14impl RegistryId {
15 pub const fn of<R: Registry + ?Sized>() -> Self {
17 Self {
18 get_registry_info: RegistryInfo::of::<R>
19 }
20 }
21
22 pub fn info(&self) -> RegistryInfo {
24 (self.get_registry_info)()
25 }
26}
27
28impl PartialEq for RegistryId {
29 fn eq(&self, other: &Self) -> bool {
30 self.info().type_id() == other.info().type_id()
31 }
32}
33
34impl Hash for RegistryId {
35 fn hash<H: Hasher>(&self, state: &mut H) {
36 self.info().type_id().hash(state)
37 }
38}