#[cfg(feature = "sqlite")]
extern crate sqlite;
use std::ops::Deref;
use std::rc::Rc;
use std::{error, fmt, result};
use driver::Driver;
pub struct Error(String);
pub type Result<T> = result::Result<T, Error>;
struct Safe<T: Driver>(Rc<T>);
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Type {
Binary,
Float,
Integer,
String,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
Binary(Vec<u8>),
Float(f64),
Integer(i64),
String(String),
}
macro_rules! raise(
($message:expr) => (
return Err(::Error($message.to_string()));
);
);
macro_rules! ok(
($result:expr) => (
match $result {
Ok(result) => result,
Err(error) => raise!(error),
}
);
);
impl fmt::Debug for Error {
#[inline]
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(formatter)
}
}
impl fmt::Display for Error {
#[inline]
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(formatter)
}
}
impl error::Error for Error {
#[inline]
fn description(&self) -> &str {
&self.0
}
}
impl<T: Driver> Safe<T> {
#[inline]
fn new(driver: T) -> Safe<T> {
Safe(Rc::new(driver))
}
}
impl<T: Driver> Clone for Safe<T> {
#[inline]
fn clone(&self) -> Self {
Safe(self.0.clone())
}
}
impl<T: Driver> Deref for Safe<T> {
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
&*self.0
}
}
pub mod driver;
pub mod prelude;
pub mod statement;
mod database;
pub use database::Database;