questdb 0.1.3

Connector for questdb
Documentation
use std::fmt::Formatter;
use serde::Serialize;

pub enum Atomicity {
    Strict,
    Relaxed,
}

impl std::fmt::Display for Atomicity {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Atomicity::Strict => write!(f, "strict"),
            Atomicity::Relaxed => write!(f, "relaxed"),
        }
    }
}

#[derive(Copy, Clone, Serialize)]
#[allow(dead_code)]
pub enum Schema {
    Boolean,
    Byte,
    Short,
    Char,
    Int,
    Float,
    Symbol,
    String,
    Long,
    Date,
    Double,
    Binary,
    Long256,
    Timestamp,
}

impl std::fmt::Display for Schema {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Schema::Boolean => write!(f, "BOOLEAN"),
            Schema::Byte => write!(f, "BYTE"),
            Schema::Short => write!(f, "SHORT"),
            Schema::Char => write!(f, "CHAR"),
            Schema::Int => write!(f, "INT"),
            Schema::Float => write!(f, "FLOAT"),
            Schema::Symbol => write!(f, "SYMBOL"),
            Schema::String => write!(f, "STRING"),
            Schema::Long => write!(f, "LONG"),
            Schema::Date => write!(f, "DATE"),
            Schema::Timestamp => write!(f, "TIMESTAMP"),
            Schema::Double => write!(f, "DOUBLE"),
            Schema::Binary => write!(f, "BINARY"),
            Schema::Long256 => write!(f, "LONG256"),
        }
    }
}

#[macro_export]
macro_rules! new_schema {
    ( $( ($n:expr, $t:expr) ),* ) => {
        {
            let mut temp_map = Vec::new();
            $(
                temp_map.push(crate::types::SchemaMap::new($n, $t));
            )*
            temp_map
        }
    };
}

#[derive(Serialize)]
pub struct SchemaMap {
    #[serde(rename(serialize = "name"))]
    column_name: String,
    #[serde(rename(serialize = "type"))]
    column_type: Schema,
}

impl SchemaMap {
    pub fn new(name: &str, column: Schema) -> Self {
        SchemaMap {
            column_name: name.to_string(),
            column_type: column,
        }
    }
}