mod establish;
mod executor;
mod worker;
use std::fmt::{self, Debug, Formatter};
use futures_core::future::BoxFuture;
use rsfbclient_native::{DynLink, NativeFbClient};
use sqlx_core::connection::Connection;
use sqlx_core::error::Error;
use sqlx_core::transaction::Transaction;
use self::worker::ConnectionWorker;
use crate::{FbConnectOptions, FbError, Firebird};
pub struct FbConnection {
pub(crate) worker: ConnectionWorker,
pub(crate) row_channel_size: usize,
}
pub(crate) struct ConnectionState {
conn: rsfbclient::Connection<NativeFbClient<DynLink>>,
}
impl Connection for FbConnection {
type Options = FbConnectOptions;
type Database = Firebird;
fn close(self) -> BoxFuture<'static, Result<(), Error>> {
todo!()
}
fn close_hard(self) -> BoxFuture<'static, Result<(), Error>> {
todo!()
}
fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>> {
todo!()
}
fn begin(&mut self) -> BoxFuture<'_, Result<Transaction<'_, Self::Database>, Error>>
where
Self: Sized,
{
todo!()
}
fn shrink_buffers(&mut self) {
todo!()
}
fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> {
todo!()
}
fn should_flush(&self) -> bool {
todo!()
}
}
impl Debug for FbConnection {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("FbConnection")
.field("row_channel_size", &self.row_channel_size)
.field("cached_statements_size", &self.cached_statements_size())
.finish()
}
}
impl FbConnectOptions {
pub(crate) fn establish(&self) -> Result<ConnectionState, Error> {
let conn = self.builder.connect().map_err(FbError::from)?;
Ok(ConnectionState { conn })
}
}