diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-04-21 15:39:47 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-04-21 15:44:04 +0200 |
commit | 0395d1be7052ed9fd7ad344281ccd297abe9c804 (patch) | |
tree | 0a9d803c86403d4ac4faf1997f63897a845209be | |
parent | 52b459a757a176524c1b17b0a511c8e9d84f1cbb (diff) |
ipc: Use platform!.
-rw-r--r-- | ipc/src/assuan/socket.rs | 11 | ||||
-rw-r--r-- | ipc/src/gnupg.rs | 8 |
2 files changed, 9 insertions, 10 deletions
diff --git a/ipc/src/assuan/socket.rs b/ipc/src/assuan/socket.rs index 8aeef881..3084f935 100644 --- a/ipc/src/assuan/socket.rs +++ b/ipc/src/assuan/socket.rs @@ -27,15 +27,13 @@ pub(crate) type IpcStream = tokio::net::UnixStream; /// /// This function panics if not called from within a Tokio runtime. pub(crate) fn sock_connect(path: impl AsRef<Path>) -> Result<IpcStream> { - - #[cfg(unix)] - { + platform! { + unix => { let stream = std::os::unix::net::UnixStream::connect(path)?; stream.set_nonblocking(true)?; Ok(tokio::net::UnixStream::from_std(stream)?) - } - #[cfg(windows)] - { + }, + windows => { use std::net::{Ipv4Addr, TcpStream}; let rendezvous = read_port_and_nonce(path.as_ref())?; @@ -72,6 +70,7 @@ pub(crate) fn sock_connect(path: impl AsRef<Path>) -> Result<IpcStream> { stream.set_nonblocking(true)?; Ok(tokio::net::TcpStream::from_std(stream)?) + }, } } diff --git a/ipc/src/gnupg.rs b/ipc/src/gnupg.rs index 86fe4f85..d4ef9772 100644 --- a/ipc/src/gnupg.rs +++ b/ipc/src/gnupg.rs @@ -101,6 +101,7 @@ impl Context { /// Whether we're dealing with gpg that expects Windows or Unix-style paths. #[derive(Copy, Clone)] + #[allow(dead_code)] enum Mode { Windows, Unix @@ -108,10 +109,9 @@ impl Context { impl Mode { fn native() -> Self { - match () { - _ if cfg!(windows) => Mode::Windows, - _ if cfg!(unix) => Mode::Unix, - _ => unimplemented!(), + platform! { + unix => Mode::Unix, + windows => Mode::Windows, } } } |