pub struct PgAsyncConnection { /* private fields */ }Expand description
Async PostgreSQL connection.
This connection uses asupersync’s TCP stream for non-blocking I/O and supports the extended query protocol for parameter binding.
Implementations§
Source§impl PgAsyncConnection
impl PgAsyncConnection
Sourcepub async fn connect(_cx: &Cx, config: PgConfig) -> Outcome<Self, Error>
pub async fn connect(_cx: &Cx, config: PgConfig) -> Outcome<Self, Error>
Establish a new async connection to the PostgreSQL server.
Sourcepub async fn query_async(
&mut self,
cx: &Cx,
sql: &str,
params: &[Value],
) -> Outcome<Vec<Row>, Error>
pub async fn query_async( &mut self, cx: &Cx, sql: &str, params: &[Value], ) -> Outcome<Vec<Row>, Error>
Run a parameterized query and return all rows.
Sourcepub async fn execute_async(
&mut self,
cx: &Cx,
sql: &str,
params: &[Value],
) -> Outcome<u64, Error>
pub async fn execute_async( &mut self, cx: &Cx, sql: &str, params: &[Value], ) -> Outcome<u64, Error>
Execute a statement and return rows affected.
Sourcepub async fn insert_async(
&mut self,
cx: &Cx,
sql: &str,
params: &[Value],
) -> Outcome<i64, Error>
pub async fn insert_async( &mut self, cx: &Cx, sql: &str, params: &[Value], ) -> Outcome<i64, Error>
Execute an INSERT and return the inserted id.
PostgreSQL requires RETURNING to retrieve generated IDs. This method
expects the SQL to return a single-row, single-column result set
containing an integer id.
Sourcepub async fn prepare_async(
&mut self,
cx: &Cx,
sql: &str,
) -> Outcome<PreparedStatement, Error>
pub async fn prepare_async( &mut self, cx: &Cx, sql: &str, ) -> Outcome<PreparedStatement, Error>
Prepare a server-side statement and return a reusable handle.
pub async fn query_prepared_async( &mut self, cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> Outcome<Vec<Row>, Error>
pub async fn execute_prepared_async( &mut self, cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> Outcome<u64, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PgAsyncConnection
impl RefUnwindSafe for PgAsyncConnection
impl Send for PgAsyncConnection
impl Sync for PgAsyncConnection
impl Unpin for PgAsyncConnection
impl UnwindSafe for PgAsyncConnection
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).