37 lines
666 B
Rust
37 lines
666 B
Rust
//! Shared Types for different Database drivers
|
|
use std::any::Any;
|
|
|
|
#[derive(Debug)]
|
|
struct Type(pub Box<dyn Any>);
|
|
|
|
/// Enum struct for mapping between database and Rust types
|
|
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
|
|
struct SQLType<T> {
|
|
value: Option<T>,
|
|
}
|
|
|
|
fn is_str(s: &(dyn Any)) {
|
|
s.is::<&str>()
|
|
}
|
|
|
|
fn is_string(s: &(dyn Any)) {
|
|
s.is::<String>()
|
|
}
|
|
|
|
fn is_bool(v: &(dyn Any)) {
|
|
v.is::<bool>()
|
|
}
|
|
|
|
impl<T> SQLType<T> {
|
|
pub fn is_some(&self) -> bool {
|
|
match *self {
|
|
SQLType::None => false,
|
|
_ => true,
|
|
}
|
|
}
|
|
|
|
pub fn is_none(&self) -> bool {
|
|
!self.is_some()
|
|
}
|
|
}
|