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
|
use crate::patio::types::PatioDataLayout;
pub(crate) enum PatioDataValue {
Array {
element_layout: PatioDataLayout,
elements: Vec<PatioDataValue>,
},
Bool(bool),
Byte(u8),
DataPtr(PatioDataPtrValue),
Int(PatioIntValue),
Int32(PatioIntValue),
Struct {
elements: Vec<PatioDataValue>,
},
}
impl PatioDataValue {
pub(crate) fn layout(&self) -> PatioDataLayout {
match self {
PatioDataValue::Array {
element_layout,
elements,
} => PatioDataLayout::array(element_layout.clone(), elements.len().try_into().unwrap()),
PatioDataValue::Bool(_) => PatioDataLayout::Bool,
PatioDataValue::Byte(_) => PatioDataLayout::Byte,
PatioDataValue::DataPtr(_) => PatioDataLayout::DataPtr,
PatioDataValue::Int(_) => PatioDataLayout::Int,
PatioDataValue::Int32(_) => PatioDataLayout::Int32,
PatioDataValue::Struct { elements } => {
PatioDataLayout::struct_(elements.iter().map(|element| element.layout()).collect())
}
}
}
}
#[derive(Debug)]
pub(crate) enum PatioDataPtrValue {
DataElement { name: String },
Null,
}
#[derive(Debug)]
pub(crate) enum PatioIntValue {
ByteOffsetOf {
layout: PatioDataLayout,
element_offsets: Vec<u32>,
},
ByteSizeOf {
layout: PatioDataLayout,
},
Literal {
value: i32,
},
}
|