rbdc_oracle/
driver.rs

1use crate::options::OracleConnectOptions;
2use crate::connection::OracleConnection;
3use futures_core::future::BoxFuture;
4use rbdc::db::{ConnectOptions, Connection};
5use rbdc::db::{Driver, Placeholder};
6use rbdc::{Error, impl_exchange};
7
8#[derive(Debug)]
9pub struct OracleDriver {}
10
11impl Driver for OracleDriver {
12    fn name(&self) -> &str {
13        "oracle"
14    }
15
16    fn connect(&self, _url: &str) -> BoxFuture<Result<Box<dyn Connection>, Error>> {
17        Box::pin(async move {
18            unimplemented!();
19        })
20    }
21
22    fn connect_opt<'a>(
23        &'a self,
24        opt: &'a dyn ConnectOptions,
25    ) -> BoxFuture<Result<Box<dyn Connection>, Error>> {
26        let opt = opt.downcast_ref::<OracleConnectOptions>().unwrap();
27        Box::pin(async move {
28            let conn = OracleConnection::establish(opt).await?;
29            Ok(Box::new(conn) as Box<dyn Connection>)
30        })
31    }
32
33    fn default_option(&self) -> Box<dyn ConnectOptions> {
34        Box::new(OracleConnectOptions::default())
35    }
36}
37
38impl Placeholder for OracleDriver {
39    fn exchange(&self, sql: &str) -> String {
40        impl_exchange(":",1,sql)
41    }
42}
43
44impl OracleDriver{
45    pub fn pub_exchange(&self, sql: &str) -> String{
46        self.exchange(sql)
47    }
48}