summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-05-21 15:43:52 +0200
committerYorhel <git@yorhel.nl>2019-05-21 15:43:55 +0200
commit58f99898d2f0c3957f2f348f7c5da0c48702b4d1 (patch)
treec33b9ab6a4f27b9a9cb710fc6570fd4d6892dafd
parentefbc366c27ec5fa9b9fe57712e184a1aa0158775 (diff)
Add From<..> impls for Listener
Not sure how I had forgotten these.
-rw-r--r--lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib.rs b/lib.rs
index f892115..7a0a0a1 100644
--- a/lib.rs
+++ b/lib.rs
@@ -235,6 +235,19 @@ pub enum Listener {
Unix(unix::UnixListener)
}
+impl From<net::TcpListener> for Listener {
+ fn from(s: net::TcpListener) -> Listener {
+ Listener::Inet(s)
+ }
+}
+
+#[cfg(unix)]
+impl From<unix::UnixListener> for Listener {
+ fn from(s: unix::UnixListener) -> Listener {
+ Listener::Unix(s)
+ }
+}
+
impl Listener {
pub fn bind(s: &SocketAddr) -> io::Result<Listener> {
match s {