Debian Codegraph @

src/transaction.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-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
4 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::executorrust-analyzer cargo sqlx-core 0.8.3 executor/::Executorrust-analyzer cargo sqlx-core 0.8.3 executor/Executor#;
5
6 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
7
8 pub(craterust-analyzer cargo sqlx-postgres 0.8.3 crate/) use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::transactionrust-analyzer cargo sqlx-core 0.8.3 transaction/::*;
9
10 /// Implementation of [`TransactionManager`] for PostgreSQL.
11 pub struct PgTransactionManagerrust-analyzer cargo sqlx-postgres 0.8.3 transaction/PgTransactionManager#;
12
13 impl TransactionManagerrust-analyzer cargo sqlx-core 0.8.3 transaction/TransactionManager# for PgTransactionManagerrust-analyzer cargo sqlx-postgres 0.8.3 transaction/PgTransactionManager# {
14 type Databaserust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]Database# = Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#;
15
16 fn beginrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]begin().(conn: &mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#) -> 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#>> {
17 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 {
18 let rollback = Rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#::newrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`]new().(conn);
19 let query = begin_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/begin_ansi_transaction_sql().(rollback.connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn..innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth.);
20 rollback.connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn..queue_simple_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]queue_simple_query().(&query)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
21 rollback.connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn..innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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;
22 rollback.connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn..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().;
23 rollback.defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`]defuse().();
24
25 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
26 })
27 }
28
29 fn commitrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]commit().(conn: &mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#) -> 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#>> {
30 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 {
31 if conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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 {
32 conn.executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`][Deref]deref().commit_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/commit_ansi_transaction_sql().(conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth.))
33 .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().;
34
35 conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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;
36 }
37
38 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
39 })
40 }
41
42 fn rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]rollback().(conn: &mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#) -> 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#>> {
43 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 {
44 if conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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 {
45 conn.executerust-analyzer cargo sqlx-core 0.8.3 executor/Executor#execute().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`][Deref]deref().rollback_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/rollback_ansi_transaction_sql().(
46 conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth.,
47 ))
48 .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().;
49
50 conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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;
51 }
52
53 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
54 })
55 }
56
57 fn start_rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]start_rollback().(conn: &mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#) {
58 if conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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 {
59 conn.queue_simple_queryrust-analyzer cargo sqlx-postgres 0.8.3 connection/impl#[PgConnection]queue_simple_query().(&rollback_ansi_transaction_sqlrust-analyzer cargo sqlx-core 0.8.3 transaction/rollback_ansi_transaction_sql().(conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth.))
60 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("BUG: Rollback query somehow too large for protocol");
61
62 conn.innerrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#inner..transaction_depthrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnectionInner#transaction_depth. 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;
63 }
64 }
65 }
66
67 struct Rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#<'c> {
68 connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn.: &'c mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#,
69 defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#defuse.: bool,
70 }
71
72 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#<'_> {
73 fn droprust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'_>`][Drop]drop().(&mut self) {
74 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#defuse. {
75 PgTransactionManagerrust-analyzer cargo sqlx-postgres 0.8.3 transaction/PgTransactionManager#::start_rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[PgTransactionManager][TransactionManager]start_rollback().(self.connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn.)
76 }
77 }
78 }
79
80 impl<'c> Rollbackrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#<'c> {
81 fn newrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`]new().(conn: &'c mut PgConnectionrust-analyzer cargo sqlx-postgres 0.8.3 connection/PgConnection#) -> Selfrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`] {
82 Selfrust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`] {
83 connrust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#conn.,
84 defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#defuse.: false,
85 }
86 }
87 fn defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/impl#[`Rollback<'c>`]defuse().(mut self) {
88 self.defuserust-analyzer cargo sqlx-postgres 0.8.3 transaction/Rollback#defuse. = true;
89 }
90 }