Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only build ipc transport on *nix systems #185

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading