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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Stable dataset identities and checked chunk-local addressing.
use core::fmt;
/// Stable identity of one logical dataset.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct DatasetId(u64);
impl DatasetId {
/// Dataset identity used by transitional constructors that receive only a
/// parsed structure and therefore have no caller-owned global identity.
pub const LEGACY: Self = Self(0);
/// Creates an identity from the caller's stable value.
#[must_use]
pub const fn new(value: u64) -> Self {
Self(value)
}
/// Returns the caller's stable value.
#[must_use]
pub const fn get(self) -> u64 {
self.0
}
}
impl fmt::Display for DatasetId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
/// Stable identity of one chunk within a dataset.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct ChunkId(u64);
impl ChunkId {
/// Creates an identity from the caller's stable value.
#[must_use]
pub const fn new(value: u64) -> Self {
Self(value)
}
/// Returns the caller's stable value.
#[must_use]
pub const fn get(self) -> u64 {
self.0
}
}
impl fmt::Display for ChunkId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
/// Stable caller identity for one spatial occurrence of a resident chunk.
///
/// A chunk can be drawn more than once with distinct transforms or shared
/// templates. Spatial relations therefore address an occurrence as well as a
/// dataset, chunk and logical row.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct ChunkOccurrenceId(u64);
impl ChunkOccurrenceId {
/// Creates a stable caller-owned occurrence identity.
#[must_use]
pub const fn new(value: u64) -> Self {
Self(value)
}
/// Returns the underlying stable value.
#[must_use]
pub const fn get(self) -> u64 {
self.0
}
}
impl fmt::Display for ChunkOccurrenceId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
/// Stable row identity in the full logical dataset.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct LogicalRow(u64);
impl LogicalRow {
/// Creates a logical row from the caller's stable value.
#[must_use]
pub const fn new(value: u64) -> Self {
Self(value)
}
/// Returns the full-dataset row value.
#[must_use]
pub const fn get(self) -> u64 {
self.0
}
}
impl fmt::Display for LogicalRow {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
/// Dense row index valid only inside one resident chunk.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct LocalRow(u32);
impl LocalRow {
/// Creates a chunk-local row.
#[must_use]
pub const fn new(value: u32) -> Self {
Self(value)
}
/// Returns the local GPU-compatible index.
#[must_use]
pub const fn get(self) -> u32 {
self.0
}
}
#[cfg(test)]
#[path = "identity_tests.rs"]
mod tests;