geam_core/runtime/value/
custom.rs1use ecow::EcoString;
2
3use super::Value;
4use crate::plan::CustomType;
5
6#[derive(Debug, Clone, PartialEq)]
7pub struct CustomValue {
8 type_: CustomType,
9 constructor_name: EcoString,
10 constructor_index: usize,
11 fields: Vec<CustomFieldValue>,
12}
13
14#[derive(Debug, Clone, PartialEq)]
15pub struct CustomFieldValue {
16 label: Option<EcoString>,
17 value: Value,
18}
19
20impl CustomValue {
21 pub(crate) fn from_evaluated(
22 type_: CustomType,
23 constructor_name: EcoString,
24 constructor_index: usize,
25 fields: Vec<CustomFieldValue>,
26 ) -> Self {
27 Self {
28 type_,
29 constructor_name,
30 constructor_index,
31 fields,
32 }
33 }
34
35 pub fn type_(&self) -> &CustomType {
36 &self.type_
37 }
38
39 pub fn constructor_name(&self) -> &EcoString {
40 &self.constructor_name
41 }
42
43 pub fn constructor_index(&self) -> usize {
44 self.constructor_index
45 }
46
47 pub fn fields(&self) -> &[CustomFieldValue] {
48 &self.fields
49 }
50}
51
52impl CustomFieldValue {
53 pub(crate) fn from_evaluated(label: Option<EcoString>, value: Value) -> Self {
54 Self { label, value }
55 }
56
57 pub fn label(&self) -> Option<&EcoString> {
58 self.label.as_ref()
59 }
60
61 pub fn value(&self) -> &Value {
62 &self.value
63 }
64}