Skip to content

Commit ecc0acb

Browse files
authored
Merge pull request #678 from sfackler/fix-send
Make postgres::Client Send again
2 parents 49ecba4 + db90323 commit ecc0acb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

postgres/src/connection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ pub struct Connection {
1616
runtime: Runtime,
1717
connection: Pin<Box<dyn Stream<Item = Result<AsyncMessage, Error>> + Send>>,
1818
notifications: VecDeque<Notification>,
19-
notice_callback: Arc<dyn Fn(DbError)>,
19+
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
2020
}
2121

2222
impl Connection {
2323
pub fn new<S, T>(
2424
runtime: Runtime,
2525
connection: tokio_postgres::Connection<S, T>,
26-
notice_callback: Arc<dyn Fn(DbError)>,
26+
notice_callback: Arc<dyn Fn(DbError) + Sync + Send>,
2727
) -> Connection
2828
where
2929
S: AsyncRead + AsyncWrite + Unpin + 'static + Send,

postgres/src/test.rs

+9
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,12 @@ fn explicit_close() {
499499
let client = Client::connect("host=localhost port=5433 user=postgres", NoTls).unwrap();
500500
client.close().unwrap();
501501
}
502+
503+
#[test]
504+
fn check_send() {
505+
fn is_send<T: Send>() {}
506+
507+
is_send::<Client>();
508+
is_send::<Statement>();
509+
is_send::<Transaction<'_>>();
510+
}

0 commit comments

Comments
 (0)