Add UniqueConnec::is_alive (#339)

This commit is contained in:
Pierre Krieger 2018-07-19 14:00:13 +02:00 committed by GitHub
parent 0cfaa23908
commit 6acc0c7c5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,6 +212,18 @@ impl<T> UniqueConnec<T> {
UniqueConnecInner::Full { .. } => UniqueConnecState::Full,
}
}
/// Returns true if the object has a pending or active connection. Returns false if the object
/// is empty or the connection has errored earlier.
#[inline]
pub fn is_alive(&self) -> bool {
match self.state() {
UniqueConnecState::Empty => false,
UniqueConnecState::Errored => false,
UniqueConnecState::Pending => true,
UniqueConnecState::Full => true,
}
}
}
impl<T> Clone for UniqueConnec<T> {