Reorder methods

This commit is contained in:
Steven Fackler 2020-01-31 14:01:16 -08:00
parent 27635a20ca
commit 4bf40cd1d3
2 changed files with 35 additions and 35 deletions

View File

@ -443,6 +443,33 @@ impl Client {
Ok(Transaction::new(&mut self.runtime, transaction))
}
/// Returns a builder for a transaction with custom settings.
///
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
/// attributes.
///
/// # Examples
///
/// ```no_run
/// use postgres::{Client, IsolationLevel, NoTls};
///
/// # fn main() -> Result<(), postgres::Error> {
/// let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
///
/// let mut transaction = client.build_transaction()
/// .isolation_level(IsolationLevel::RepeatableRead)
/// .start()?;
/// transaction.execute("UPDATE foo SET bar = 10", &[])?;
/// // ...
///
/// transaction.commit()?;
/// # Ok(())
/// # }
/// ```
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
TransactionBuilder::new(&mut self.runtime, self.client.build_transaction())
}
/// Constructs a cancellation token that can later be used to request
/// cancellation of a query running on this connection.
///
@ -483,33 +510,6 @@ impl Client {
CancelToken::new(self.client.cancel_token())
}
/// Returns a builder for a transaction with custom settings.
///
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
/// attributes.
///
/// # Examples
///
/// ```no_run
/// use postgres::{Client, IsolationLevel, NoTls};
///
/// # fn main() -> Result<(), postgres::Error> {
/// let mut client = Client::connect("host=localhost user=postgres", NoTls)?;
///
/// let mut transaction = client.build_transaction()
/// .isolation_level(IsolationLevel::RepeatableRead)
/// .start()?;
/// transaction.execute("UPDATE foo SET bar = 10", &[])?;
/// // ...
///
/// transaction.commit()?;
/// # Ok(())
/// # }
/// ```
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
TransactionBuilder::new(&mut self.runtime, self.client.build_transaction())
}
/// Determines if the client's connection has already closed.
///
/// If this returns `true`, the client is no longer usable.

View File

@ -447,6 +447,14 @@ impl Client {
Ok(Transaction::new(self))
}
/// Returns a builder for a transaction with custom settings.
///
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
/// attributes.
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
TransactionBuilder::new(self)
}
/// Constructs a cancellation token that can later be used to request
/// cancellation of a query running on the connection associated with
/// this client.
@ -460,14 +468,6 @@ impl Client {
}
}
/// Returns a builder for a transaction with custom settings.
///
/// Unlike the `transaction` method, the builder can be used to control the transaction's isolation level and other
/// attributes.
pub fn build_transaction(&mut self) -> TransactionBuilder<'_> {
TransactionBuilder::new(self)
}
/// Attempts to cancel an in-progress query.
///
/// The server provides no information about whether a cancellation attempt was successful or not. An error will