Debian Codegraph @

src/any/connection/mod.rs

raw symbols SCIP
1 use futures_corerust-analyzer cargo futures-core 0.3.34 crate/::futurerust-analyzer cargo futures-core 0.3.34 future/::BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#;
2
3 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::anyrust-analyzer cargo sqlx-core 0.8.3 any/::{Anyrust-analyzer cargo sqlx-core 0.8.3 any/database/Any#, AnyConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#};
4 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::connectionrust-analyzer cargo sqlx-core 0.8.3 connection/::{ConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 connection/ConnectOptions#, Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#};
5 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
6
7 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::databaserust-analyzer cargo sqlx-core 0.8.3 database/::Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#;
8 pub use backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/::AnyConnectionBackendrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#;
9
10 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/::Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#;
11
12 mod backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/;
13 mod executorrust-analyzer cargo sqlx-core 0.8.3 any/connection/executor/;
14
15 /// A connection to _any_ SQLx database.
16 ///
17 /// The database driver used is determined by the scheme
18 /// of the connection url.
19 ///
20 /// ```text
21 /// postgres://postgres@localhost/test
22 /// sqlite://a.sqlite
23 /// ```
24 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
25 pub struct AnyConnectionrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection# {
26 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn AnyConnectionBackendrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#>,
27 }
28
29 impl AnyConnectionrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection# {
30 /// Returns the name of the database backend in use (e.g. PostgreSQL, MySQL, SQLite, etc.)
31 pub fn backend_namerust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]backend_name().(&self) -> &str {
32 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..namerust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#name().()
33 }
34
35 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) fn connectrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]connect().(options: &AnyConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<Selfrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]>> {
36 Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(async {
37 let driver = craterust-analyzer cargo sqlx-core 0.8.3 crate/::anyrust-analyzer cargo sqlx-core 0.8.3 any/::driverrust-analyzer cargo sqlx-core 0.8.3 any/driver/::from_urlrust-analyzer cargo sqlx-core 0.8.3 any/driver/from_url().(&options.database_urlrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#database_url.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
38 (driver.connectrust-analyzer cargo sqlx-core 0.8.3 any/driver/AnyDriver#connect.)(options).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().
39 })
40 }
41
42 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) fn connect_with_dbrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]connect_with_db().<DB: Databaserust-analyzer cargo sqlx-core 0.8.3 database/Database#>(
43 options: &AnyConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#,
44 ) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<Selfrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]>>
45 where
46 DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection#: AnyConnectionBackendrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#,
47 <DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection# as Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#>::Optionsrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Options#:
48 for<'a> TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&'a AnyConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#, Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error# = Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>,
49 {
50 let res = TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#try_from().(options);
51
52 Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::pinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]pin().(async {
53 let options: <DB::Connectionrust-analyzer cargo sqlx-core 0.8.3 database/Database#Connection# as Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#>::Optionsrust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Options# = res?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
54
55 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AnyConnectionrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection# {
56 backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(options.connectrust-analyzer cargo sqlx-core 0.8.3 connection/ConnectOptions#connect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/impl#[`Pin<P>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
57 })
58 })
59 }
60
61 #[cfg(feature = "migrate")]
62 pub(craterust-analyzer cargo sqlx-core 0.8.3 crate/) fn get_migraterust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection]get_migrate().(
63 &mut self,
64 ) -> craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<&mut (dyn craterust-analyzer cargo sqlx-core 0.8.3 crate/::migraterust-analyzer cargo sqlx-core 0.8.3 migrate/::Migraterust-analyzer cargo sqlx-core 0.8.3 migrate/migrate/Migrate# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + 'static)> {
65 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..as_migraterust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#as_migrate().()
66 }
67 }
68
69 impl Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection# for AnyConnectionrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection# {
70 type Databaserust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]Database# = Anyrust-analyzer cargo sqlx-core 0.8.3 any/database/Any#;
71
72 type Optionsrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]Options# = AnyConnectOptionsrust-analyzer cargo sqlx-core 0.8.3 any/options/AnyConnectOptions#;
73
74 fn closerust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]close().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'static, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> {
75 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..closerust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#close().()
76 }
77
78 fn close_hardrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]close_hard().(self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'static, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> {
79 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..closerust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#close().()
80 }
81
82 fn pingrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]ping().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> {
83 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..pingrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#ping().()
84 }
85
86 fn beginrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]begin().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#<'_, Selfrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]::Databaserust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Database#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>
87 where
88 Selfrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
89 {
90 Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#::beginrust-analyzer cargo sqlx-core 0.8.3 transaction/impl#[`Transaction<'c, DB>`]begin().(self)
91 }
92
93 fn cached_statements_sizerust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]cached_statements_size().(&self) -> usize {
94 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..cached_statements_sizerust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#cached_statements_size().()
95 }
96
97 fn clear_cached_statementsrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]clear_cached_statements().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, craterust-analyzer cargo sqlx-core 0.8.3 crate/::Resultrust-analyzer cargo sqlx-core 0.8.3 error/Result#<()>> {
98 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..clear_cached_statementsrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#clear_cached_statements().()
99 }
100
101 fn shrink_buffersrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]shrink_buffers().(&mut self) {
102 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..shrink_buffersrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#shrink_buffers().()
103 }
104
105 #[doc(hidden)]
106 fn flushrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]flush().(&mut self) -> BoxFuturerust-analyzer cargo futures-core 0.3.34 future/BoxFuture#<'_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>> {
107 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..flushrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#flush().()
108 }
109
110 #[doc(hidden)]
111 fn should_flushrust-analyzer cargo sqlx-core 0.8.3 any/connection/impl#[AnyConnection][Connection]should_flush().(&self) -> bool {
112 self.backendrust-analyzer cargo sqlx-core 0.8.3 any/connection/AnyConnection#backend..should_flushrust-analyzer cargo sqlx-core 0.8.3 any/connection/backend/AnyConnectionBackend#should_flush().()
113 }
114 }