use std::fmt::Debug;
pub trait ColumnType: Debug + PartialEq + Eq + Clone + Send + Sync {
fn from_char(value: char) -> Option<Self>;
fn to_char(&self) -> char;
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum DefaultColumnType {
Text,
Integer,
FloatingPoint,
Any,
}
impl ColumnType for DefaultColumnType {
fn from_char(value: char) -> Option<Self> {
match value {
'T' => Some(Self::Text),
'I' => Some(Self::Integer),
'R' => Some(Self::FloatingPoint),
_ => Some(Self::Any),
}
}
fn to_char(&self) -> char {
match self {
Self::Text => 'T',
Self::Integer => 'I',
Self::FloatingPoint => 'R',
Self::Any => '?',
}
}
}