pub struct PooledConnection<D: Driver> { /* private fields */ }Expand description
A database connection borrowed from a ConnectionPool.
Implements both Executor and Connection, so it can be used anywhere
a plain connection is expected. Deref-coerces to the underlying driver
connection (D::Connection) via Deref/DerefMut, giving access to
any driver-specific extension methods.
The borrowed connection is automatically returned to the pool when this
value is dropped. If you need to take full ownership of the connection
outside pool management, call ConnectionPool::detach instead.
§Obtaining a PooledConnection
Call ConnectionPool::get or ConnectionPool::timeout_get on a pool:
let mut pool = PostgresDriver::new()
.connect_pool("postgres://localhost/mydb".into(), PoolConfig::new())
.await?;
let mut conn = pool.get().await?;
Tank::create_table(&mut conn, true, true).await?;Trait Implementations§
Source§impl<D: Driver> AsMut<<D as Driver>::Connection> for PooledConnection<D>
impl<D: Driver> AsMut<<D as Driver>::Connection> for PooledConnection<D>
Source§fn as_mut(&mut self) -> &mut D::Connection
fn as_mut(&mut self) -> &mut D::Connection
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl<D: Driver> AsRef<<D as Driver>::Connection> for PooledConnection<D>
impl<D: Driver> AsRef<<D as Driver>::Connection> for PooledConnection<D>
Source§fn as_ref(&self) -> &D::Connection
fn as_ref(&self) -> &D::Connection
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<D: Driver> Connection for PooledConnection<D>
impl<D: Driver> Connection for PooledConnection<D>
Source§fn connect(
_driver: &D,
_url: Cow<'static, str>,
) -> impl Future<Output = Result<<D as Driver>::Connection>> + Sendwhere
Self: Sized,
fn connect(
_driver: &D,
_url: Cow<'static, str>,
) -> impl Future<Output = Result<<D as Driver>::Connection>> + Sendwhere
Self: Sized,
Establishes a connection (or pool) to the database specified by the URL. Read more
Source§fn begin(
&mut self,
) -> impl Future<Output = Result<<D as Driver>::Transaction<'_>>> + Send
fn begin( &mut self, ) -> impl Future<Output = Result<<D as Driver>::Transaction<'_>>> + Send
Starts a new transaction on this connection. Read more
Source§impl<D: Driver> Deref for PooledConnection<D>
impl<D: Driver> Deref for PooledConnection<D>
Source§impl<D: Driver> DerefMut for PooledConnection<D>
impl<D: Driver> DerefMut for PooledConnection<D>
Source§impl<D: Driver> Executor for PooledConnection<D>
impl<D: Driver> Executor for PooledConnection<D>
Source§fn accepts_multiple_statements(&self) -> bool
fn accepts_multiple_statements(&self) -> bool
Checks if the driver supports multiple SQL statements in a single request.
Source§fn prepare<'s>(
&'s mut self,
query: impl AsQuery<D> + 's,
) -> impl Future<Output = Result<Query<D>>> + Send
fn prepare<'s>( &'s mut self, query: impl AsQuery<D> + 's, ) -> impl Future<Output = Result<Query<D>>> + Send
Prepares a query for execution, returning a handle to the prepared statement.
Source§fn do_prepare(
&mut self,
sql: String,
) -> impl Future<Output = Result<Query<D>>> + Send
fn do_prepare( &mut self, sql: String, ) -> impl Future<Output = Result<Query<D>>> + Send
Internal hook for implementing prepared statement support.
Source§fn run<'s>(
&'s mut self,
query: impl AsQuery<D> + 's,
) -> impl Stream<Item = Result<QueryResult>> + Send
fn run<'s>( &'s mut self, query: impl AsQuery<D> + 's, ) -> impl Stream<Item = Result<QueryResult>> + Send
Executes a query and streams the results (rows or affected counts).
Source§fn fetch<'s>(
&'s mut self,
query: impl AsQuery<D> + 's,
) -> impl Stream<Item = Result<Row>> + Send
fn fetch<'s>( &'s mut self, query: impl AsQuery<D> + 's, ) -> impl Stream<Item = Result<Row>> + Send
Executes a query and streams the resulting rows, ignoring affected counts.
Source§fn execute<'s>(
&'s mut self,
query: impl AsQuery<D> + 's,
) -> impl Future<Output = Result<RowsAffected>> + Send
fn execute<'s>( &'s mut self, query: impl AsQuery<D> + 's, ) -> impl Future<Output = Result<RowsAffected>> + Send
Executes a query and returns the total number of affected rows.
Auto Trait Implementations§
impl<D> !RefUnwindSafe for PooledConnection<D>
impl<D> !UnwindSafe for PooledConnection<D>
impl<D> Freeze for PooledConnection<D>
impl<D> Send for PooledConnection<D>
impl<D> Sync for PooledConnection<D>
impl<D> Unpin for PooledConnection<D>
impl<D> UnsafeUnpin for PooledConnection<D>
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> Casing<T> for T
impl<T> Casing<T> for T
Source§fn to_case(&self, case: Case<'_>) -> String
fn to_case(&self, case: Case<'_>) -> String
Convert the string into the given case. It will reference
self and create a new
String with the same pattern and delimiter as case. It will split on boundaries
defined at Boundary::defaults(). Read moreSource§fn set_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
fn set_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
Creates a
StateConverter struct initialized with the boundaries provided. Read moreSource§fn remove_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
fn remove_boundaries(&self, bs: &[Boundary]) -> StateConverter<'_, T>
Creates a
StateConverter struct initialized without the boundaries
provided. Read moreSource§fn from_case(&self, case: Case<'_>) -> StateConverter<'_, T>
fn from_case(&self, case: Case<'_>) -> StateConverter<'_, T>
Start the case conversion by storing the boundaries associated with the given case. Read more
Source§fn remove_empty(&self) -> StateConverter<'_, T>
fn remove_empty(&self) -> StateConverter<'_, T>
Creates a
StateConverter with the RemoveEmpty pattern prepended.
This filters out empty words before conversion, useful when splitting
produces empty words from leading, trailing, and duplicate delimiters. Read moreimpl<T> Parsable for T
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)