mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-20 00:54:18 +00:00
Implement Acquire for PgListener (#3550)
* Implement Acquire for PgListener * Add a test which checks that PgListener implements Acquire * Drop unnecessary call to `.acquire()` * Rename test channel to avoid conflict with other tests
This commit is contained in:
@@ -5,7 +5,9 @@ use std::str::from_utf8;
|
||||
use futures_channel::mpsc;
|
||||
use futures_core::future::BoxFuture;
|
||||
use futures_core::stream::{BoxStream, Stream};
|
||||
use futures_util::{FutureExt, StreamExt, TryStreamExt};
|
||||
use futures_util::{FutureExt, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use sqlx_core::acquire::Acquire;
|
||||
use sqlx_core::transaction::Transaction;
|
||||
use sqlx_core::Either;
|
||||
|
||||
use crate::describe::Describe;
|
||||
@@ -328,6 +330,19 @@ impl Drop for PgListener {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c> Acquire<'c> for &'c mut PgListener {
|
||||
type Database = Postgres;
|
||||
type Connection = &'c mut PgConnection;
|
||||
|
||||
fn acquire(self) -> BoxFuture<'c, Result<Self::Connection, Error>> {
|
||||
self.connection().boxed()
|
||||
}
|
||||
|
||||
fn begin(self) -> BoxFuture<'c, Result<Transaction<'c, Self::Database>, Error>> {
|
||||
self.connection().and_then(|c| c.begin()).boxed()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'c> Executor<'c> for &'c mut PgListener {
|
||||
type Database = Postgres;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user