diff --git a/postgres/src/client.rs b/postgres/src/client.rs index 2ffe9caa..8dd7b05d 100644 --- a/postgres/src/client.rs +++ b/postgres/src/client.rs @@ -60,6 +60,10 @@ impl Client { self.batch_execute("BEGIN")?; Ok(Transaction::new(self)) } + + pub fn is_closed(&self) -> bool { + self.0.is_closed() + } } impl From for Client { diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index 449cfa48..fbcb81b7 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -98,6 +98,10 @@ impl Client { pub fn batch_execute(&mut self, query: &str) -> BatchExecute { BatchExecute(self.0.batch_execute(query)) } + + pub fn is_closed(&self) -> bool { + self.0.is_closed() + } } #[must_use = "futures do nothing unless polled"] diff --git a/tokio-postgres/src/proto/client.rs b/tokio-postgres/src/proto/client.rs index fdc80765..20bc841a 100644 --- a/tokio-postgres/src/proto/client.rs +++ b/tokio-postgres/src/proto/client.rs @@ -60,6 +60,10 @@ impl Client { })) } + pub fn is_closed(&self) -> bool { + self.0.sender.is_closed() + } + pub fn downgrade(&self) -> WeakClient { WeakClient(Arc::downgrade(&self.0)) }