sqlx_firebird/connection/
mod.rs

1//
2// Copyright © 2023, RedSoft
3// License: MIT
4//
5
6mod establish;
7mod executor;
8mod worker;
9
10use std::fmt::{self, Debug, Formatter};
11
12use futures_core::future::BoxFuture;
13use rsfbclient_native::{DynLink, NativeFbClient};
14use sqlx_core::connection::Connection;
15use sqlx_core::error::Error;
16use sqlx_core::transaction::Transaction;
17
18use self::worker::ConnectionWorker;
19use crate::{FbConnectOptions, FbError, Firebird};
20
21pub struct FbConnection {
22    pub(crate) worker: ConnectionWorker,
23    pub(crate) row_channel_size: usize,
24}
25
26pub(crate) struct ConnectionState {
27    conn: rsfbclient::Connection<NativeFbClient<DynLink>>,
28}
29
30impl Connection for FbConnection {
31    type Options = FbConnectOptions;
32
33    type Database = Firebird;
34
35    fn close(self) -> BoxFuture<'static, Result<(), Error>> {
36        todo!()
37    }
38
39    fn close_hard(self) -> BoxFuture<'static, Result<(), Error>> {
40        todo!()
41    }
42
43    fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>> {
44        todo!()
45    }
46
47    fn begin(&mut self) -> BoxFuture<'_, Result<Transaction<'_, Self::Database>, Error>>
48    where
49        Self: Sized,
50    {
51        todo!()
52    }
53
54    fn shrink_buffers(&mut self) {
55        todo!()
56    }
57
58    fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> {
59        todo!()
60    }
61
62    fn should_flush(&self) -> bool {
63        todo!()
64    }
65}
66
67impl Debug for FbConnection {
68    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
69        f.debug_struct("FbConnection")
70            .field("row_channel_size", &self.row_channel_size)
71            .field("cached_statements_size", &self.cached_statements_size())
72            .finish()
73    }
74}
75
76impl FbConnectOptions {
77    pub(crate) fn establish(&self) -> Result<ConnectionState, Error> {
78        let conn = self.builder.connect().map_err(FbError::from)?;
79        Ok(ConnectionState { conn })
80    }
81}