sqlx_rxqlite/connection/
mod.rs

1use std::fmt::{self, Debug, Formatter};
2
3use futures_core::future::BoxFuture;
4//use futures_util::FutureExt;
5use futures_util::future;
6pub(crate) use sqlx_core::connection::*;
7use sqlx_core::transaction::Transaction;
8
9use crate::error::Error;
10use crate::options::RXQLiteConnectOptions;
11use crate::RXQLite;
12
13mod establish;
14mod executor;
15
16pub struct RXQLiteConnection {
17  pub inner: rxqlite_client::RXQLiteClient,
18}
19
20impl Debug for RXQLiteConnection {
21    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
22        f.debug_struct("RXQLiteConnection").finish()
23    }
24}
25
26impl Connection for RXQLiteConnection {
27    type Database = RXQLite;
28
29    type Options = RXQLiteConnectOptions;
30
31    fn close(self) -> BoxFuture<'static, Result<(), Error>> {
32        Box::pin(async move { Ok(()) })
33    }
34
35    fn close_hard(self) -> BoxFuture<'static, Result<(), Error>> {
36        Box::pin(async move { Ok(()) })
37    }
38
39    fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>> {
40        Box::pin(async move { Ok(()) })
41    }
42
43    #[doc(hidden)]
44    fn flush(&mut self) -> BoxFuture<'_, Result<(), Error>> {
45        //self.stream.wait_until_ready().boxed()
46        Box::pin(future::ok(()))
47    }
48
49    fn cached_statements_size(&self) -> usize {
50        //self.cache_statement.len()
51        0
52    }
53
54    fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<(), Error>> {
55        Box::pin(async move {
56            /*
57            while let Some((statement_id, _)) = self.cache_statement.remove_lru() {
58                self.stream
59                    .send_packet(StmtClose {
60                        statement: statement_id,
61                    })
62                    .await?;
63            }
64            */
65            Ok(())
66        })
67    }
68
69    #[doc(hidden)]
70    fn should_flush(&self) -> bool {
71        //!self.stream.write_buffer().is_empty()
72        false
73    }
74
75    fn begin(&mut self) -> BoxFuture<'_, Result<Transaction<'_, Self::Database>, Error>>
76    where
77        Self: Sized,
78    {
79        Transaction::begin(self)
80    }
81
82    fn shrink_buffers(&mut self) {
83        //self.stream.shrink_buffers();
84    }
85}