Skip to content

Commit

Permalink
only build ipc transport on *nix systems (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk authored Jan 15, 2024
1 parent 59be7a0 commit 28ac4a4
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/transport/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "ipc-transport")]
#[cfg(all(feature = "ipc-transport", target_family = "unix"))]
mod ipc;
#[cfg(feature = "tcp-transport")]
mod tcp;
Expand Down Expand Up @@ -29,16 +29,20 @@ pub(crate) async fn connect(endpoint: &Endpoint) -> ZmqResult<(FramedIo, Endpoin
Endpoint::Tcp(_host, _port) => {
do_if_enabled!("tcp-transport", tcp::connect(_host, *_port).await)
}
Endpoint::Ipc(_path) => do_if_enabled!(
"ipc-transport",
if let Some(path) = _path {
ipc::connect(path).await
} else {
Err(crate::error::ZmqError::Socket(
"Cannot connect to an unnamed ipc socket",
))
Endpoint::Ipc(_path) => {
#[cfg(all(feature = "ipc-transport", target_family = "unix"))]
{
if let Some(path) = _path {
ipc::connect(path).await
} else {
Err(crate::error::ZmqError::Socket(
"Cannot connect to an unnamed ipc socket",
))
}
}
),
#[cfg(not(all(feature = "ipc-transport", target_family = "unix")))]
panic!("IPC transport is not available on this platform")
}
}
}

Expand Down Expand Up @@ -68,16 +72,20 @@ where
"tcp-transport",
tcp::begin_accept(_host, _port, _cback).await
),
Endpoint::Ipc(_path) => do_if_enabled!(
"ipc-transport",
if let Some(path) = _path {
ipc::begin_accept(&path, _cback).await
} else {
Err(crate::error::ZmqError::Socket(
"Cannot begin accepting peers at an unnamed ipc socket",
))
Endpoint::Ipc(_path) => {
#[cfg(all(feature = "ipc-transport", target_family = "unix"))]
{
if let Some(path) = _path {
ipc::begin_accept(&path, _cback).await
} else {
Err(crate::error::ZmqError::Socket(
"Cannot begin accepting peers at an unnamed ipc socket",
))
}
}
),
#[cfg(not(all(feature = "ipc-transport", target_family = "unix")))]
panic!("IPC transport is not available on this platform")
}
}
}

Expand Down

0 comments on commit 28ac4a4

Please sign in to comment.