welds_sqlx_mssql/connection/
mod.rs1use crate::common::StatementCache;
2use crate::connection::stream::MssqlStream;
3use crate::error::Error;
4use crate::executor::Executor;
5use crate::statement::MssqlStatementMetadata;
6use crate::{Mssql, MssqlConnectOptions};
7use futures_core::future::BoxFuture;
8use futures_util::{FutureExt, TryFutureExt};
9use sqlx_core::connection::{Connection, LogSettings};
10use sqlx_core::transaction::Transaction;
11use std::fmt::{self, Debug, Formatter};
12use std::sync::Arc;
13
14mod establish;
15mod executor;
16mod prepare;
17mod stream;
18mod tls;
19
20pub struct MssqlConnection {
21 pub(crate) stream: MssqlStream,
22 pub(crate) cache_statement: StatementCache<Arc<MssqlStatementMetadata>>,
23 log_settings: LogSettings,
24}
25
26impl Debug for MssqlConnection {
27 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
28 f.debug_struct("MssqlConnection").finish()
29 }
30}
31
32impl Connection for MssqlConnection {
33 type Database = Mssql;
34
35 type Options = MssqlConnectOptions;
36
37 fn close(mut self) -> BoxFuture<'static, Result<(), Error>> {
38 Box::pin(async move {
39 self.stream.shutdown().await?;
40 Ok(())
41 })
42 }
43
44 fn close_hard(mut self) -> BoxFuture<'static, Result<(), Error>> {
45 Box::pin(async move {
46 self.stream.shutdown().await?;
47 Ok(())
48 })
49 }
50
51 fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>> {
74 self.execute("/* SQLx ping */").map_ok(|_| ()).boxed()
76 }
77
78 fn begin(&mut self) -> BoxFuture<'_, Result<Transaction<'_, Self::Database>, Error>>
79 where
80 Self: Sized,
81 {
82 Transaction::begin(self)
83 }
84
85 #[doc(hidden)]
86 fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> {
87 self.stream.wait_until_ready().boxed()
88 }
89
90 fn shrink_buffers(&mut self) {
91 self.stream.shrink_buffers();
92 }
93
94 #[doc(hidden)]
95 fn should_flush(&self) -> bool {
96 todo!("FIX");
97 }
99}