1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::fmt;
macro_rules! define_id {
($(#[$meta:meta])* $name:ident) => {
$(#[$meta])*
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct $name(u64);
impl $name {
pub const fn new(raw: u64) -> Self {
Self(raw)
}
pub const fn get(self) -> u64 {
self.0
}
}
impl From<u64> for $name {
fn from(value: u64) -> Self {
Self::new(value)
}
}
impl From<$name> for u64 {
fn from(value: $name) -> Self {
value.get()
}
}
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
};
}
define_id!(WidgetId);
define_id!(
/// Identifies a host render/input target.
///
/// A `WindowId` may refer to a native platform window or to an embedded
/// viewport/region owned by a host application. Platform events, runtime
/// scheduling, and `SceneFrame` submission use this ID as the common target
/// identity.
WindowId
);
define_id!(SurfaceId);
define_id!(ImageHandle);
define_id!(FontHandle);
define_id!(TimerToken);
define_id!(AsyncWakeToken);