formualizer_eval/engine/
vertex.rs1#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
3pub struct VertexId(pub(crate) u32);
4
5impl VertexId {
6 pub(crate) fn new(id: u32) -> Self {
7 Self(id)
8 }
9
10 pub(crate) fn as_index(self) -> usize {
11 self.0 as usize
12 }
13
14 #[allow(dead_code)]
16 fn shard_id(&self) -> u16 {
17 (self.0 >> 16) as u16
18 }
19
20 #[allow(dead_code)]
21 fn local_id(&self) -> u16 {
22 self.0 as u16
23 }
24}
25
26#[repr(u8)]
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28pub enum VertexKind {
29 Empty = 0,
31
32 Cell = 1,
34
35 FormulaScalar = 2,
37
38 FormulaArray = 3,
40
41 NamedScalar = 4,
43
44 NamedArray = 5,
46
47 InfiniteRange = 6,
49
50 Range = 7,
52
53 External = 8,
55}
56
57impl VertexKind {
58 #[inline]
59 pub fn from_tag(tag: u8) -> Self {
60 match tag {
61 0 => VertexKind::Empty,
62 1 => VertexKind::Cell,
63 2 => VertexKind::FormulaScalar,
64 3 => VertexKind::FormulaArray,
65 4 => VertexKind::NamedScalar,
66 5 => VertexKind::NamedArray,
67 6 => VertexKind::InfiniteRange,
68 7 => VertexKind::Range,
69 8 => VertexKind::External,
70 _ => VertexKind::Empty,
71 }
72 }
73
74 #[inline]
75 pub fn to_tag(self) -> u8 {
76 self as u8
77 }
78}