mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-01 12:11:20 +00:00
Add UniqueConnec::is_alive (#339)
This commit is contained in:
parent
0cfaa23908
commit
6acc0c7c5f
@ -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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user