Struct af_postgres::Client [−][src]
A client for executing stataments on a Postgres connection.
The client can be cloned and shared across tasks or threads. All clones share the same connection which executes statements in the order they are received. Statements are sent to Postgres with automatic pipelining to maximize throughput when using multiple clients simultaneously.
Implementations
impl Client
[src]
pub async fn execute(
&self,
statement: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64>
[src]
&self,
statement: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<u64>
Executes a statement and returns the number of rows affected.
pub fn is_closed(&self) -> bool
[src]
Returns true
if the client is disconnected.
pub async fn batch_execute(&self, statements: impl AsRef<str>) -> Result
[src]
Executes a batch of statements separated by semicolons.
If a statement fails, this function will return the error and stop executing the batch. When executing a batch of statements including transactions, it is the user's responsibility to roll back any running transactions if this function fails.
This function is intended to execute, for example, a SQL file to create the initial schema of a database. When executing individual statements, other functions should be preferred.
pub async fn begin(&self) -> Result
[src]
Begins a transaction on the associated connection.
All clones of this client share the same transaction. They will execute statements within the transaction until this client or a clone of it commits or rolls back the transaction. It is the user's responsibilty to ensure consistency when creating a transaction using multiple clones concurrently.
pub async fn commit(&self) -> Result
[src]
Commits the running transaction.
pub async fn prepare(&self, query: impl AsRef<str>) -> Result<Statement>
[src]
Prepares a statement.
Prepared statements can be used repeatedly, but only by the same
Client
that created them.
pub async fn query(
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<RowStream>
[src]
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<RowStream>
Executes a statement and returns its results as a stream of rows.
pub async fn query_opt(
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>>
[src]
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<Option<Row>>
Executes a statement and optionally returns the first row of the results.
If no rows are returned, this function returns None
.
pub async fn query_one(
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, QueryOneError>
[src]
&self,
query: &impl ToStatement + ?Sized,
params: &[&(dyn ToSql + Sync)]
) -> Result<Row, QueryOneError>
Executes a statement and returns the first row of the results.
If no rows are returned, this function returns a [NoRowsReturned
] error.
pub async fn rollback(&self) -> Result
[src]
Rolls back the running transaction.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,