1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::fmt::Display;
use chrono::{DateTime, Utc};
use uuid::Uuid;
#[derive(Clone, Debug)]
pub enum Attribute {
Null,
Boolean(bool),
Integer(i64),
Decimal(f64),
String(String),
DateTime(DateTime<Utc>),
Uuid(Uuid),
}
impl Display for Attribute {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Attribute::Null => f.write_str("null"),
Attribute::Boolean(value) => f.write_fmt(format_args!("{}", value)),
Attribute::Integer(value) => f.write_fmt(format_args!("{}", value)),
Attribute::Decimal(value) => f.write_fmt(format_args!("{}", value)),
Attribute::String(value) => f.write_fmt(format_args!("'{}'", value)),
Attribute::DateTime(value) => f.write_fmt(format_args!("'{}'", value)),
Attribute::Uuid(value) => f.write_fmt(format_args!("'{}'", value.as_hyphenated())),
}
}
}