Skip to content

Commit 4bf40cd

Browse files
committed
Reorder methods
1 parent 27635a2 commit 4bf40cd

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

postgres/src/client.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,33 @@ impl Client {
443443
Ok(Transaction::new(&mut self.runtime, transaction))
444444
}
445445

446+
/// Returns a builder for a transaction with custom settings.
447+
///
448+
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
449+
/// attributes.
450+
///
451+
/// # Examples
452+
///
453+
/// ```no_run
454+
/// use postgres::{Client, IsolationLevel, NoTls};
455+
///
456+
/// # fn main() -> Result<(), postgres::Error> {
457+
/// let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
458+
///
459+
/// let mut transaction = client.build_transaction()
460+
/// .isolation_level(IsolationLevel::RepeatableRead)
461+
/// .start()?;
462+
/// transaction.execute("UPDATE foo SET bar = 10", &[])?;
463+
/// // ...
464+
///
465+
/// transaction.commit()?;
466+
/// # Ok(())
467+
/// # }
468+
/// ```
469+
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
470+
TransactionBuilder::new(&mut self.runtime, self.client.build_transaction())
471+
}
472+
446473
/// Constructs a cancellation token that can later be used to request
447474
/// cancellation of a query running on this connection.
448475
///
@@ -483,33 +510,6 @@ impl Client {
483510
CancelToken::new(self.client.cancel_token())
484511
}
485512

486-
/// Returns a builder for a transaction with custom settings.
487-
///
488-
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
489-
/// attributes.
490-
///
491-
/// # Examples
492-
///
493-
/// ```no_run
494-
/// use postgres::{Client, IsolationLevel, NoTls};
495-
///
496-
/// # fn main() -> Result<(), postgres::Error> {
497-
/// let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
498-
///
499-
/// let mut transaction = client.build_transaction()
500-
/// .isolation_level(IsolationLevel::RepeatableRead)
501-
/// .start()?;
502-
/// transaction.execute("UPDATE foo SET bar = 10", &[])?;
503-
/// // ...
504-
///
505-
/// transaction.commit()?;
506-
/// # Ok(())
507-
/// # }
508-
/// ```
509-
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
510-
TransactionBuilder::new(&mut self.runtime, self.client.build_transaction())
511-
}
512-
513513
/// Determines if the client's connection has already closed.
514514
///
515515
/// If this returns `true`, the client is no longer usable.

tokio-postgres/src/client.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ impl Client {
447447
Ok(Transaction::new(self))
448448
}
449449

450+
/// Returns a builder for a transaction with custom settings.
451+
///
452+
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
453+
/// attributes.
454+
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
455+
TransactionBuilder::new(self)
456+
}
457+
450458
/// Constructs a cancellation token that can later be used to request
451459
/// cancellation of a query running on the connection associated with
452460
/// this client.
@@ -460,14 +468,6 @@ impl Client {
460468
}
461469
}
462470

463-
/// Returns a builder for a transaction with custom settings.
464-
///
465-
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
466-
/// attributes.
467-
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
468-
TransactionBuilder::new(self)
469-
}
470-
471471
/// Attempts to cancel an in-progress query.
472472
///
473473
/// The server provides no information about whether a cancellation attempt was successful or not. An error will

0 commit comments

Comments
 (0)