devalang_core/core/shared/
value.rs1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4use crate::core::{
5 parser::statement::{Statement, StatementKind},
6 shared::duration::Duration,
7};
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
10pub enum Value {
11 Boolean(bool),
12 Number(f32),
13 Duration(Duration),
14 Identifier(String),
15 String(String),
16 Array(Vec<Value>),
17 Map(HashMap<String, Value>),
18 Block(Vec<Statement>),
19 Sample(String),
20 Beat(String),
21 Statement(Box<Statement>),
22 StatementKind(Box<StatementKind>),
23 Unknown,
24 Null,
25}
26
27impl Value {
28 pub fn get(&self, key: &str) -> Option<&Value> {
29 if let Value::Map(map) = self {
30 map.get(key)
31 } else {
32 None
33 }
34 }
35}