Mercurial > crates > systemd-socket
diff src/error.rs @ 16:bc76507dd878
Fixed conditional compilation based on OS
A mistake was causing systemd to never enable and the tests were too
clever to detect that. Not sure what to do with it.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Tue, 22 Dec 2020 13:58:47 +0100 |
parents | f740dadd2948 |
children | f6334887e3c8 |
line wrap: on
line diff
--- a/src/error.rs Tue Dec 22 13:56:56 2020 +0100 +++ b/src/error.rs Tue Dec 22 13:58:47 2020 +0100 @@ -19,15 +19,15 @@ pub(crate) enum ParseErrorInner { #[error("failed to parse socket address")] ResolvAddr(#[from] crate::resolv_addr::ResolvAddrError), - #[cfg(all(linux, feature = "enable_systemd"))] + #[cfg(all(target_os = "linux", feature = "enable_systemd"))] #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] InvalidCharacter { string: String, c: char, pos: usize, }, - #[cfg(all(linux, feature = "enable_systemd"))] + #[cfg(all(target_os = "linux", feature = "enable_systemd"))] #[error("systemd socket name {string} is {len} characters long which is more than the limit 255")] LongSocketName { string: String, len: usize, }, - #[cfg(not(all(linux, feature = "enable_systemd")))] - #[cfg_attr(not(linux), error("can't parse {0} because systemd is not supported on this operating system"))] - #[cfg_attr(linux, error("can't parse {0} because systemd support was disabled during build"))] + #[cfg(not(all(target_os = "linux", feature = "enable_systemd")))] + #[cfg_attr(not(target_os = "linux"), error("can't parse {0} because systemd is not supported on this operating system"))] + #[cfg_attr(target_os = "linux", error("can't parse {0} because systemd support was disabled during build"))] SystemdUnsupported(String), } @@ -66,14 +66,14 @@ BindFailed { addr: std::net::SocketAddr, #[source] error: io::Error, }, #[error("failed to bind {addr}")] BindOrResolvFailed { addr: crate::resolv_addr::ResolvAddr, #[source] error: io::Error, }, - #[cfg(all(linux, feature = "enable_systemd"))] + #[cfg(all(target_os = "linux", feature = "enable_systemd"))] #[error("failed to receive descriptors with names")] ReceiveDescriptors(#[source] crate::systemd_sockets::Error), #[error("missing systemd socket {0} - a typo or an attempt to bind twice")] - #[cfg(all(linux, feature = "enable_systemd"))] + #[cfg(all(target_os = "linux", feature = "enable_systemd"))] MissingDescriptor(String), #[error("the systemd socket {0} is not an internet socket")] - #[cfg(all(linux, feature = "enable_systemd"))] + #[cfg(all(target_os = "linux", feature = "enable_systemd"))] NotInetSocket(String), }