Reorder methods
This commit is contained in:
parent
27635a20ca
commit
4bf40cd1d3
@ -443,6 +443,33 @@ impl Client {
|
|||||||
Ok(Transaction::new(&mut self.runtime, transaction))
|
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
|
/// Constructs a cancellation token that can later be used to request
|
||||||
/// cancellation of a query running on this connection.
|
/// cancellation of a query running on this connection.
|
||||||
///
|
///
|
||||||
@ -483,33 +510,6 @@ impl Client {
|
|||||||
CancelToken::new(self.client.cancel_token())
|
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.
|
/// Determines if the client's connection has already closed.
|
||||||
///
|
///
|
||||||
/// If this returns `true`, the client is no longer usable.
|
/// If this returns `true`, the client is no longer usable.
|
||||||
|
@ -447,6 +447,14 @@ impl Client {
|
|||||||
Ok(Transaction::new(self))
|
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
|
/// Constructs a cancellation token that can later be used to request
|
||||||
/// cancellation of a query running on the connection associated with
|
/// cancellation of a query running on the connection associated with
|
||||||
/// this client.
|
/// 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.
|
/// Attempts to cancel an in-progress query.
|
||||||
///
|
///
|
||||||
/// The server provides no information about whether a cancellation attempt was successful or not. An error will
|
/// The server provides no information about whether a cancellation attempt was successful or not. An error will
|
||||||
|
Loading…
Reference in New Issue
Block a user