diff options
Diffstat (limited to 'lib/rs/src/transport/socket.rs')
-rw-r--r-- | lib/rs/src/transport/socket.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/rs/src/transport/socket.rs b/lib/rs/src/transport/socket.rs index 275bcd459..48d6dda13 100644 --- a/lib/rs/src/transport/socket.rs +++ b/lib/rs/src/transport/socket.rs @@ -20,6 +20,9 @@ use std::io; use std::io::{ErrorKind, Read, Write}; use std::net::{Shutdown, TcpStream, ToSocketAddrs}; +#[cfg(unix)] +use std::os::unix::net::UnixStream; + use super::{ReadHalf, TIoChannel, WriteHalf}; use crate::{new_transport_error, TransportErrorKind}; @@ -166,3 +169,15 @@ impl Write for TTcpChannel { self.if_set(|s| s.flush()) } } + +#[cfg(unix)] +impl TIoChannel for UnixStream { + fn split(self) -> crate::Result<(ReadHalf<Self>, WriteHalf<Self>)> + where + Self: Sized, + { + let socket_rx = self.try_clone().unwrap(); + + Ok((ReadHalf::new(self), WriteHalf::new(socket_rx))) + } +} |