1use std::fmt::Formatter;
2use serde::Serialize;
3
4pub enum Atomicity {
5 Strict,
6 Relaxed,
7}
8
9impl std::fmt::Display for Atomicity {
10 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
11 match self {
12 Atomicity::Strict => write!(f, "strict"),
13 Atomicity::Relaxed => write!(f, "relaxed"),
14 }
15 }
16}
17
18#[derive(Copy, Clone, Serialize)]
19#[allow(dead_code)]
20pub enum Schema {
21 Boolean,
22 Byte,
23 Short,
24 Char,
25 Int,
26 Float,
27 Symbol,
28 String,
29 Long,
30 Date,
31 Double,
32 Binary,
33 Long256,
34 Timestamp,
35}
36
37impl std::fmt::Display for Schema {
38 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
39 match self {
40 Schema::Boolean => write!(f, "BOOLEAN"),
41 Schema::Byte => write!(f, "BYTE"),
42 Schema::Short => write!(f, "SHORT"),
43 Schema::Char => write!(f, "CHAR"),
44 Schema::Int => write!(f, "INT"),
45 Schema::Float => write!(f, "FLOAT"),
46 Schema::Symbol => write!(f, "SYMBOL"),
47 Schema::String => write!(f, "STRING"),
48 Schema::Long => write!(f, "LONG"),
49 Schema::Date => write!(f, "DATE"),
50 Schema::Timestamp => write!(f, "TIMESTAMP"),
51 Schema::Double => write!(f, "DOUBLE"),
52 Schema::Binary => write!(f, "BINARY"),
53 Schema::Long256 => write!(f, "LONG256"),
54 }
55 }
56}
57
58#[macro_export]
59macro_rules! new_schema {
60 ( $( ($n:expr, $t:expr) ),* ) => {
61 {
62 let mut temp_map = Vec::new();
63 $(
64 temp_map.push(crate::types::SchemaMap::new($n, $t));
65 )*
66 temp_map
67 }
68 };
69}
70
71#[derive(Serialize)]
72pub struct SchemaMap {
73 #[serde(rename(serialize = "name"))]
74 column_name: String,
75 #[serde(rename(serialize = "type"))]
76 column_type: Schema,
77}
78
79impl SchemaMap {
80 pub fn new(name: &str, column: Schema) -> Self {
81 SchemaMap {
82 column_name: name.to_string(),
83 column_type: column,
84 }
85 }
86}