pub struct PgConnection<State> { /* private fields */ }Expand description
Typestate wrapper around a pooled Postgres client.
Implementations§
Source§impl PgConnection<Idle>
impl PgConnection<Idle>
Source§impl PgConnection<Idle>
impl PgConnection<Idle>
Sourcepub async fn execute_batch(
&mut self,
sql: &str,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>
Auto-commit batch (BEGIN/COMMIT around it).
§Errors
Returns SqlMiddlewareDbError if the batch execution fails.
Source§impl PgConnection<InTx>
impl PgConnection<InTx>
Sourcepub async fn execute_batch(
&mut self,
sql: &str,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &mut self, sql: &str, ) -> Result<(), SqlMiddlewareDbError>
Execute batch inside the open transaction.
§Errors
Returns SqlMiddlewareDbError if executing the batch fails.
Source§impl PgConnection<Idle>
impl PgConnection<Idle>
Source§impl PgConnection<InTx>
impl PgConnection<InTx>
Sourcepub async fn select(
&mut self,
query: &str,
params: &[RowValues],
) -> Result<ResultSet, SqlMiddlewareDbError>
pub async fn select( &mut self, query: &str, params: &[RowValues], ) -> Result<ResultSet, SqlMiddlewareDbError>
Execute SELECT inside the open transaction.
§Errors
Returns SqlMiddlewareDbError if executing the select fails.
Sourcepub fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>
pub fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>
Start a query builder within the open transaction.
Source§impl PgConnection<Idle>
impl PgConnection<Idle>
Sourcepub async fn begin(self) -> Result<PgConnection<InTx>, SqlMiddlewareDbError>
pub async fn begin(self) -> Result<PgConnection<InTx>, SqlMiddlewareDbError>
Begin an explicit transaction.
§Errors
Returns SqlMiddlewareDbError if starting the transaction fails.
Source§impl PgConnection<InTx>
impl PgConnection<InTx>
Sourcepub async fn commit(self) -> Result<PgConnection<Idle>, SqlMiddlewareDbError>
pub async fn commit(self) -> Result<PgConnection<Idle>, SqlMiddlewareDbError>
Sourcepub async fn rollback(self) -> Result<PgConnection<Idle>, SqlMiddlewareDbError>
pub async fn rollback(self) -> Result<PgConnection<Idle>, SqlMiddlewareDbError>
Trait Implementations§
Source§impl BeginTx for PgConnection<Idle>
impl BeginTx for PgConnection<Idle>
Source§impl<State> Drop for PgConnection<State>
impl<State> Drop for PgConnection<State>
Source§impl Queryable for PgConnection<Idle>
impl Queryable for PgConnection<Idle>
fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>
Source§impl Queryable for PgConnection<InTx>
impl Queryable for PgConnection<InTx>
fn query<'a>(&'a mut self, sql: &'a str) -> QueryBuilder<'a, 'a>
Source§impl TxConn for PgConnection<InTx>
impl TxConn for PgConnection<InTx>
Source§impl TypedConnOps for PgConnection<Idle>
impl TypedConnOps for PgConnection<Idle>
fn execute_batch( &mut self, sql: &str, ) -> impl Future<Output = Result<(), SqlMiddlewareDbError>>
fn dml( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<usize, SqlMiddlewareDbError>>
fn select( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<ResultSet, SqlMiddlewareDbError>>
Source§impl TypedConnOps for PgConnection<InTx>
impl TypedConnOps for PgConnection<InTx>
fn execute_batch( &mut self, sql: &str, ) -> impl Future<Output = Result<(), SqlMiddlewareDbError>>
fn dml( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<usize, SqlMiddlewareDbError>>
fn select( &mut self, query: &str, params: &[RowValues], ) -> impl Future<Output = Result<ResultSet, SqlMiddlewareDbError>>
Auto Trait Implementations§
impl<State> Freeze for PgConnection<State>
impl<State> !RefUnwindSafe for PgConnection<State>
impl<State> Send for PgConnection<State>where
State: Send,
impl<State> Sync for PgConnection<State>where
State: Sync,
impl<State> Unpin for PgConnection<State>where
State: Unpin,
impl<State> !UnwindSafe for PgConnection<State>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more