2019-04-02 16:35:52 -04:00
|
|
|
//! Shared Types for different Database drivers
|
2019-04-03 20:58:22 -04:00
|
|
|
use std::any::Any;
|
|
|
|
|
2019-04-10 20:11:26 -04:00
|
|
|
/// The Wild type is any type, until examined
|
|
|
|
pub type Wild = Box<dyn Any>;
|
|
|
|
|
2019-04-03 20:58:22 -04:00
|
|
|
#[derive(Debug)]
|
2019-04-10 20:11:26 -04:00
|
|
|
struct Type(pub Wild);
|
2019-04-03 20:58:22 -04:00
|
|
|
|
|
|
|
/// Enum struct for mapping between database and Rust types
|
|
|
|
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
|
2019-04-10 20:11:26 -04:00
|
|
|
enum SQLType<T> {
|
2019-04-04 16:39:05 -04:00
|
|
|
Boolean(T),
|
|
|
|
SmallInt(T),
|
|
|
|
BigInt(T),
|
|
|
|
Text(T),
|
|
|
|
None,
|
2019-04-03 20:58:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> SQLType<T> {
|
2019-04-04 16:39:05 -04:00
|
|
|
pub fn is_some(&self) -> bool {
|
2019-04-03 20:58:22 -04:00
|
|
|
match *self {
|
|
|
|
SQLType::None => false,
|
|
|
|
_ => true,
|
|
|
|
}
|
|
|
|
}
|
2019-04-04 16:39:05 -04:00
|
|
|
|
2019-04-03 20:58:22 -04:00
|
|
|
pub fn is_none(&self) -> bool {
|
|
|
|
!self.is_some()
|
|
|
|
}
|
|
|
|
}
|