Skip to content

Commit 6502db9

Browse files
committed
Make Socket::UnixSocket only available on unix
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 994fdff commit 6502db9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/port_forwarding.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ impl From<ForwardType> for native_mux_impl::ForwardType {
3636
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
3737
pub enum Socket<'a> {
3838
/// Unix socket.
39+
#[cfg(not(windows))]
40+
#[cfg_attr(docsrs, doc(cfg(not(windows))))]
3941
UnixSocket {
4042
/// Filesystem path
4143
path: Cow<'a, Path>,
@@ -59,6 +61,7 @@ impl Socket<'_> {
5961
#[cfg(feature = "process-mux")]
6062
pub(crate) fn as_os_str(&self) -> Cow<'_, OsStr> {
6163
match self {
64+
#[cfg(not(windows))]
6265
Socket::UnixSocket { path } => Cow::Borrowed(path.as_os_str()),
6366
Socket::TcpSocket(socket) => Cow::Owned(format!("{}", socket).into()),
6467
}
@@ -71,6 +74,7 @@ impl<'a> From<Socket<'a>> for native_mux_impl::Socket<'a> {
7174
use native_mux_impl::Socket::*;
7275

7376
match socket {
77+
#[cfg(not(windows))]
7478
Socket::UnixSocket { path } => UnixSocket { path },
7579
Socket::TcpSocket(socket) => TcpSocket {
7680
port: socket.port() as u32,
@@ -83,6 +87,7 @@ impl<'a> From<Socket<'a>> for native_mux_impl::Socket<'a> {
8387
impl<'a> fmt::Display for Socket<'a> {
8488
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8589
match self {
90+
#[cfg(not(windows))]
8691
Socket::UnixSocket { path } => {
8792
write!(f, "{}", path.to_string_lossy())
8893
}

0 commit comments

Comments
 (0)