From b9e8b4868bce4bd9fdbc7c5ad0bd42c6aecb2bdc Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 21 Dec 2018 21:08:26 -0800 Subject: [PATCH] Add Client::is_closed --- postgres/src/client.rs | 4 ++++ tokio-postgres/src/lib.rs | 4 ++++ tokio-postgres/src/proto/client.rs | 4 ++++ 3 files changed, 12 insertions(+) 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)) }