csv_processor/scalar/
mod.rs1#[derive(Debug, Clone, PartialEq)]
2pub enum CellValue {
3 Str(String),
4 Float(f64),
5 Integer(i64),
6 Boolean(bool),
7 Date(String),
8 Null,
9}
10
11impl CellValue {
12 pub fn is_null(&self) -> bool {
13 matches!(self, CellValue::Null)
14 }
15
16 pub fn data_type(&self) -> &'static str {
17 match self {
18 CellValue::Str(_) => "string",
19 CellValue::Float(_) => "float",
20 CellValue::Integer(_) => "integer",
21 CellValue::Boolean(_) => "boolean",
22 CellValue::Date(_) => "date",
23 CellValue::Null => "null",
24 }
25 }
26}
27
28impl std::fmt::Display for CellValue {
29 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30 match self {
31 CellValue::Str(s) => write!(f, "{}", s),
32 CellValue::Float(n) => write!(f, "{}", n),
33 CellValue::Integer(n) => write!(f, "{}", n),
34 CellValue::Boolean(b) => write!(f, "{}", b),
35 CellValue::Date(d) => write!(f, "{}", d),
36 CellValue::Null => write!(f, ""),
37 }
38 }
39}