summaryrefslogtreecommitdiff
path: root/dhall/src/simple.rs
diff options
context:
space:
mode:
authorNadrieril2020-03-08 17:11:34 +0000
committerNadrieril2020-03-31 21:44:01 +0100
commit84796fd247eb1a13fcd092a7cd7ec2d587b261bd (patch)
tree1be14161e1181ae058329f4d6bc29cc9c8409aab /dhall/src/simple.rs
parent5a5aa49e64197899006751db72e404f4b2292d4e (diff)
Add SimpleValue type to facilitate deserialization
Diffstat (limited to '')
-rw-r--r--dhall/src/simple.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/dhall/src/simple.rs b/dhall/src/simple.rs
new file mode 100644
index 0000000..6457291
--- /dev/null
+++ b/dhall/src/simple.rs
@@ -0,0 +1,29 @@
+use std::collections::BTreeMap;
+
+use crate::syntax::LitKind;
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct SimpleValue {
+ kind: Box<SValKind>,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum SValKind {
+ Lit(LitKind),
+ Optional(Option<SimpleValue>),
+ List(Vec<SimpleValue>),
+ Record(BTreeMap<String, SimpleValue>),
+ Union(String, Option<SimpleValue>),
+ Text(String),
+}
+
+impl SimpleValue {
+ pub(crate) fn new(kind: SValKind) -> Self {
+ SimpleValue {
+ kind: Box::new(kind),
+ }
+ }
+ pub fn kind(&self) -> &SValKind {
+ self.kind.as_ref()
+ }
+}