Debian Codegraph @

src/connection/mod.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#};
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#;
3
4 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#;
5 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#;
6 use futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::FutureExtrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#;
7
8 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::commonrust-analyzer cargo sqlx-core 0.8.3 common/::StatementCacherust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/StatementCache#;
9 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
10 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::extrust-analyzer cargo sqlx-core 0.8.3 ext/::ustrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/::UStrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/UStr#;
11 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#;
12 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{
13 BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#, Closerust-analyzer cargo sqlx-postgres 0.8.3 message/close/Close#, Queryrust-analyzer cargo sqlx-postgres 0.8.3 message/query/Query#, ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#, ReceivedMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#, Terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/terminate/Terminate#,
14 TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#,
15 };
16 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::statementrust-analyzer cargo sqlx-postgres 0.8.3 statement/::PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#;
17 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::transactionrust-analyzer cargo sqlx-postgres 0.8.3 transaction/::Transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/Transaction#;
18 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#;
19 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgConnectOptionsrust-analyzer cargo sqlx-postgres 0.8.3 options/PgConnectOptions#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
20
21 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::connectionrust-analyzer cargo sqlx-core 0.8.3 connection/::*;
22
23 pub use selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/::streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/::PgStreamrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#;
24
25 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) mod describerust-analyzer cargo sqlx-postgres 0.8.3 connection/describe/;
26 mod establishrust-analyzer cargo sqlx-postgres 0.8.3 connection/establish/;
27 mod executorrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/;
28 mod saslrust-analyzer cargo sqlx-postgres 0.8.3 connection/sasl/;
29 mod streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/;
30 mod tlsrust-analyzer cargo sqlx-postgres 0.8.3 connection/tls/;
31
32 /// A connection to a PostgreSQL database.
33 pub struct PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
34 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<PgConnectionInnerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#>,
35 }
36
37 pub struct PgConnectionInnerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner# {
38 // underlying TCP or UDS stream,
39 // wrapped in a potentially TLS stream,
40 // wrapped in a buffered stream
41 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream.: PgStreamrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#,
42
43 // process id of this backend
44 // used to send cancel requests
45 #[allow(dead_code)]
46 process_idrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#process_id.: u32,
47
48 // secret key of this backend
49 // used to send cancel requests
50 #[allow(dead_code)]
51 secret_keyrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#secret_key.: u32,
52
53 // sequence of statement IDs for use in preparing statements
54 // in PostgreSQL, the statement is prepared to a user-supplied identifier
55 next_statement_idrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#next_statement_id.: StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#,
56
57 // cache statement by query string to the id and columns
58 cache_statementrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_statement.: StatementCacherust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/StatementCache#<(StatementIdrust-analyzer cargo sqlx-postgres 0.8.3 io/StatementId#, Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<PgStatementMetadatarust-analyzer cargo sqlx-postgres 0.8.3 statement/PgStatementMetadata#>)>,
59
60 // cache user-defined types by id <-> info
61 cache_type_inforust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_info.: HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#<Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#>,
62 cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid.: HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#<UStrrust-analyzer cargo sqlx-core 0.8.3 ext/ustr/UStr#, Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#>,
63 cache_elem_type_to_arrayrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_elem_type_to_array.: HashMaprust-analyzer cargo hashbrown 0.15.5 map/HashMap#<Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#, Oidrust-analyzer cargo sqlx-postgres 0.8.3 types/oid/Oid#>,
64
65 // number of ReadyForQuery messages that we are currently expecting
66 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count.: usize,
67
68 // current transaction status
69 transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_status.: TransactionStatusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/TransactionStatus#,
70 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth.: usize,
71
72 log_settingsrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#log_settings.: LogSettingsrust-analyzer cargo sqlx-core 0.8.3 connection/LogSettings#,
73 }
74
75 impl PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
76 /// the version number of the server in `libpq` format
77 pub fn server_version_numrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]server_version_num().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> {
78 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..server_version_numrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/PgStream#server_version_num.
79 }
80
81 // will return when the connection is ready for another query
82 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) async fn wait_until_readyrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]wait_until_ready().(&mut self) -> 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 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..write_buffer_mutrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]write_buffer_mut().().is_emptyrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[WriteBuffer]is_empty().() {
84 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
85 }
86
87 while self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
88 let message = self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..recvrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]recv().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
89
90 if let BackendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#::ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/BackendMessageFormat#ReadyForQuery# = message.formatrust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#format. {
91 self.handle_ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]handle_ready_for_query().(message)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
92 }
93 }
94
95 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
96 }
97
98 async fn recv_ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]recv_ready_for_query().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
99 let r: ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery# = self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..recv_expectrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]recv_expect().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
100
101 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
102 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_status. = r.transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#transaction_status.;
103
104 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
105 }
106
107 #[inline(always)]
108 fn handle_ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]handle_ready_for_query().(&mut self, message: ReceivedMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/ReceivedMessage#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
109 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count. = self
110 .innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner.
111 .pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count.
112 .checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_sub().(1)
113 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("received more ReadyForQuery messages than expected"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
114
115 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_status. = message.decoderust-analyzer cargo sqlx-postgres 0.8.3 message/impl#[ReceivedMessage]decode().::<ReadyForQueryrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..transaction_statusrust-analyzer cargo sqlx-postgres 0.8.3 message/ready_for_query/ReadyForQuery#transaction_status.;
116
117 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
118 }
119
120 /// Queue a simple query (not prepared) to execute the next time this connection is used.
121 ///
122 /// Used for rolling back transactions and releasing advisory locks.
123 #[inline(always)]
124 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) fn queue_simple_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]queue_simple_query().(&mut self, query: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
125 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..write_msgrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]write_msg().(Queryrust-analyzer cargo sqlx-postgres 0.8.3 message/query/Query#(query))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
126 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..pending_ready_for_query_countrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#pending_ready_for_query_count. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
127
128 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
129 }
130 }
131
132 impl Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
133 fn fmtrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Debug]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
134 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("PgConnection").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
135 }
136 }
137
138 impl Connectionrust-analyzer cargo sqlx-core 0.8.3 connection/Connection# for PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
139 type Databaserust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]Database# = Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#;
140
141 type Optionsrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]Options# = PgConnectOptionsrust-analyzer cargo sqlx-postgres 0.8.3 options/PgConnectOptions#;
142
143 fn closerust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]close().(mut 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#>> {
144 // The normal, graceful termination procedure is that the frontend sends a Terminate
145 // message and immediately closes the connection.
146
147 // On receipt of this message, the backend closes the
148 // connection and terminates.
149
150 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 move {
151 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..sendrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]send().(Terminaterust-analyzer cargo sqlx-postgres 0.8.3 message/terminate/Terminate#).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
152 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]shutdown().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
153
154 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
155 })
156 }
157
158 fn close_hardrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]close_hard().(mut 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#>> {
159 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 move {
160 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..shutdownrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]shutdown().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
161
162 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
163 })
164 }
165
166 fn pingrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][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#>> {
167 // Users were complaining about this showing up in query statistics on the server.
168 // By sending a comment we avoid an error if the connection was in the middle of a rowset
169 // self.execute("/* SQLx ping */").map_ok(|_| ()).boxed()
170
171 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 move {
172 // The simplest call-and-response that's possible.
173 self.write_syncrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[PgConnection]write_sync().();
174 self.wait_until_readyrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]wait_until_ready().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
175 })
176 }
177
178 fn beginrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][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-postgres 0.8.3 connection/impl#[PgConnection][Connection]::Databaserust-analyzer cargo sqlx-core 0.8.3 connection/Connection#Database#>, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>>
179 where
180 Selfrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#,
181 {
182 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)
183 }
184
185 fn cached_statements_sizerust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]cached_statements_size().(&self) -> usize {
186 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_statementrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_statement..lenrust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/impl#[`StatementCache<T>`]len().()
187 }
188
189 fn clear_cached_statementsrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]clear_cached_statements().(&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#>> {
190 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 move {
191 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_type_oidrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_type_oid..clearrust-analyzer cargo hashbrown 0.15.5 map/impl#[`HashMap<K, V, S, A>`]clear().();
192
193 let mut cleared = 0_usize;
194
195 self.wait_until_readyrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]wait_until_ready().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
196
197 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((id, _)) = self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..cache_statementrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#cache_statement..remove_lrurust-analyzer cargo sqlx-core 0.8.3 common/statement_cache/impl#[`StatementCache<T>`]remove_lru().() {
198 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..write_msgrust-analyzer cargo sqlx-postgres 0.8.3 connection/stream/impl#[PgStream]write_msg().(Closerust-analyzer cargo sqlx-postgres 0.8.3 message/close/Close#::Statementrust-analyzer cargo sqlx-postgres 0.8.3 message/close/Close#Statement#(id))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
199 cleared rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
200 }
201
202 if cleared rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
203 self.write_syncrust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[PgConnection]write_sync().();
204 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..flushrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]flush().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
205
206 self.wait_for_close_completerust-analyzer cargo sqlx-postgres 0.8.3 connection/executor/impl#[PgConnection]wait_for_close_complete().(cleared).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
207 self.recv_ready_for_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]recv_ready_for_query().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
208 }
209
210 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
211 })
212 }
213
214 fn shrink_buffersrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]shrink_buffers().(&mut self) {
215 self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..shrink_buffersrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]shrink_buffers().();
216 }
217
218 #[doc(hidden)]
219 fn flushrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][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#>> {
220 self.wait_until_readyrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]wait_until_ready().().boxedrust-analyzer cargo futures-util 0.3.34 future/future/FutureExt#boxed().()
221 }
222
223 #[doc(hidden)]
224 fn should_flushrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][Connection]should_flush().(&self) -> bool {
225 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..streamrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#stream..write_bufferrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[`BufferedSocket<S>`]write_buffer().().is_emptyrust-analyzer cargo sqlx-core 0.8.3 net/socket/buffered/impl#[WriteBuffer]is_empty().()
226 }
227 }
228
229 // Implement `AsMut<Self>` so that `PgConnection` can be wrapped in
230 // a `PgAdvisoryLockGuard`.
231 //
232 // See: https://github.com/launchbadge/sqlx/issues/2520
233 impl AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#> for PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
234 fn as_mutrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection][`AsMut<Self>`]as_mut().(&mut self) -> &mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection# {
235 self
236 }
237 }