diff --git a/postgres/src/generic_client.rs b/postgres/src/generic_client.rs index b11cb795..f2b1bf2e 100644 --- a/postgres/src/generic_client.rs +++ b/postgres/src/generic_client.rs @@ -1,13 +1,14 @@ #![allow(missing_docs)] -use tokio_postgres::Column; +use fallible_iterator::FallibleIterator; +use tokio_postgres::{Column, Notification}; use tokio_postgres::row::RowIndex; use tokio_postgres::types::FromSql; use crate::types::{BorrowToSql, ToSql, Type}; use crate::{ Client, CopyInWriter, CopyOutReader, Error, Row, RowIter, SimpleQueryMessage, Statement, - ToStatement, Transaction + ToStatement, Transaction, Notifications }; macro_rules! common { @@ -106,6 +107,8 @@ pub trait GenericClient { type Row: GenericRow; common!(Self::Transaction<'_>, Self::Error); + + fn block_for_notify(&mut self) -> Result, Self::Error>; } impl GenericClient for Client { @@ -188,6 +191,12 @@ impl GenericClient for Client { fn transaction(&mut self) -> Result, Error> { self.transaction() } + + fn block_for_notify(&mut self) -> Result, Error> { + let mut n = self.notifications(); + let mut n = n.blocking_iter(); + n.next() + } } macro_rules! transaction_common { @@ -286,6 +295,10 @@ impl GenericClient for Transaction<'_> { type Transaction<'a> = Transaction<'a> where Self: 'a; type Row = Row; transaction_common!(Self::Transaction<'_>); + + fn block_for_notify(&mut self) -> Result, Self::Error> { + Ok(None) + } } impl GenericRow for Row { diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index 7ccadfa1..0185edd6 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -201,10 +201,11 @@ where /// An asynchronous notification. #[derive(Clone, Debug)] +#[allow(missing_docs)] pub struct Notification { - process_id: i32, - channel: String, - payload: String, + pub process_id: i32, + pub channel: String, + pub payload: String, } impl Notification {