blob: 0cf6da762e4d30bd3d966f7892b78db34f814cea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use std::any::TypeId;
use std::fmt::Debug;
use std::hash::Hash;
pub trait Event: Debug + 'static
{
fn id(&self) -> Id;
}
/// The ID of a [`Event`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Id
{
inner: TypeId,
}
impl Id
{
/// Returns the id of a [`Event`];
pub fn of<EventT: Event>() -> Self
{
Self { inner: TypeId::of::<EventT>() }
}
}
|