summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {