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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};
use crate::msg_bundle::Component;
#[derive(
Copy,
Clone,
Debug,
Hash,
PartialEq,
Eq,
PartialOrd,
Ord,
ArrowField,
ArrowSerialize,
ArrowDeserialize,
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[arrow_field(transparent)]
pub struct InstanceKey(pub u64);
impl InstanceKey {
pub const SPLAT: Self = Self(u64::MAX);
#[inline]
pub fn is_splat(self) -> bool {
self == Self::SPLAT
}
#[inline]
pub fn is_specific(self) -> bool {
self != Self::SPLAT
}
#[inline]
pub fn specific_index(self) -> Option<InstanceKey> {
self.is_specific().then_some(self)
}
}
impl std::fmt::Display for InstanceKey {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.is_splat() {
"splat".fmt(f)
} else {
self.0.fmt(f)
}
}
}
impl Component for InstanceKey {
#[inline]
fn name() -> crate::ComponentName {
"rerun.instance_key".into()
}
}