sqlx_rqlite/connection/
mod.rs

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