Have Transport::Listeners produce ListenerEvents. (#1032)

Replace the listener and address pair returned from `Transport::listen_on` with just a listener that produces `ListenerEvent` values which include upgrades as well as address changes.
This commit is contained in:
Toralf Wittner
2019-04-10 10:29:21 +02:00
committed by GitHub
parent 98b2517403
commit 6917b8f543
36 changed files with 935 additions and 701 deletions

View File

@ -106,3 +106,23 @@ impl std::ops::Not for Endpoint {
}
}
impl Endpoint {
/// Is this endpoint a dialer?
pub fn is_dialer(self) -> bool {
if let Endpoint::Dialer = self {
true
} else {
false
}
}
/// Is this endpoint a listener?
pub fn is_listener(self) -> bool {
if let Endpoint::Listener = self {
true
} else {
false
}
}
}