2019-04-02 16:35:52 -04:00
|
|
|
//! Drivers
|
|
|
|
//!
|
|
|
|
//! Drivers represent a connection to a specific type of database engine
|
|
|
|
use std::fmt;
|
|
|
|
|
2019-04-03 20:58:22 -04:00
|
|
|
#[cfg(feature="postgres")]
|
2019-04-02 16:35:52 -04:00
|
|
|
mod postgres;
|
|
|
|
|
|
|
|
#[cfg(feature="sqlite")]
|
|
|
|
mod sqlite;
|
|
|
|
|
2019-04-03 20:58:22 -04:00
|
|
|
#[cfg(feature="mysql")]
|
|
|
|
mod mysql;
|
|
|
|
|
2019-04-02 16:35:52 -04:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct Connection;
|
|
|
|
|
2019-04-03 20:58:22 -04:00
|
|
|
/// Result for a db query
|
2019-04-02 16:35:52 -04:00
|
|
|
#[derive(Debug)]
|
|
|
|
struct QueryResult;
|
|
|
|
|
|
|
|
|
|
|
|
/// Database Driver Trait
|
|
|
|
///
|
|
|
|
/// Interface between the database connection library and the query builder
|
|
|
|
pub trait DatabaseDriver: fmt::Debug {
|
2019-04-03 16:29:51 -04:00
|
|
|
/// Vector version of `quote_identifier`
|
|
|
|
fn quote_identifiers(&self, identifiers: Vec<String>) -> Vec<String> {
|
|
|
|
let mut output: Vec<String> = vec![];
|
|
|
|
|
|
|
|
for identifier in identifiers {
|
|
|
|
output.push(self.quote_identifier(&identifier));
|
|
|
|
}
|
|
|
|
|
|
|
|
output
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Quote the identifiers passed, so the database does not
|
|
|
|
/// normalize the identifiers (eg, table, column, etc.)
|
|
|
|
fn quote_identifier(&self, identifier: &str) -> String;
|
|
|
|
|
2019-04-02 16:35:52 -04:00
|
|
|
/// Runs a basic sql query on the database
|
|
|
|
fn query(&self, query: &str) -> Result<(), ()>;
|
|
|
|
}
|