bk_promql_parser/parser/
value.rs1use std::fmt::{self, Display};
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum ValueType {
19 Vector,
20 Scalar,
21 Matrix,
22 String,
23}
24
25impl Display for ValueType {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 match *self {
28 ValueType::Scalar => write!(f, "scalar"),
29 ValueType::String => write!(f, "string"),
30 ValueType::Vector => write!(f, "vector"),
31 ValueType::Matrix => write!(f, "matrix"),
32 }
33 }
34}
35
36pub trait Value {
37 fn vtype(&self) -> ValueType;
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn test_value_type() {
46 assert_eq!(ValueType::Scalar.to_string(), "scalar");
47 assert_eq!(ValueType::String.to_string(), "string");
48 assert_eq!(ValueType::Vector.to_string(), "vector");
49 assert_eq!(ValueType::Matrix.to_string(), "matrix");
50 }
51}