blob: 2275ed9fa01099cc09c35c38f3aa888ddaa771fc [file] [log] [blame]
//! Macros to ease conditional code based on enabled features.
// Depending on the features not all macros are used.
#![allow(unused_macros)]
/// Feature `os-poll` enabled.
macro_rules! cfg_os_poll {
($($item:item)*) => {
$(
#[cfg(feature = "os-poll")]
#[cfg_attr(docsrs, doc(cfg(feature = "os-poll")))]
$item
)*
}
}
/// Feature `os-poll` disabled.
macro_rules! cfg_not_os_poll {
($($item:item)*) => {
$(
#[cfg(not(feature = "os-poll"))]
$item
)*
}
}
/// One of the `tcp`, `udp`, `uds` features enabled.
#[cfg(unix)]
macro_rules! cfg_net {
($($item:item)*) => {
$(
#[cfg(any(feature = "tcp", feature = "udp", feature = "uds"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp", feature = "udp", feature = "uds"))))]
$item
)*
}
}
/// One of the features enabled that needs `IoSource`. That is `tcp`, or `udp`,
/// or on Unix `uds` or `pipe`.
macro_rules! cfg_io_source {
($($item:item)*) => {
$(
#[cfg(any(feature = "tcp", feature = "udp", all(unix, any(feature = "uds", feature = "pipe"))))]
#[cfg_attr(docsrs, doc(any(feature = "tcp", feature = "udp", all(unix, any(feature = "uds", feature = "pipe")))))]
$item
)*
}
}
/// One of the `tcp`, `udp` features enabled.
#[cfg(windows)]
macro_rules! cfg_net {
($($item:item)*) => {
$(
#[cfg(any(feature = "tcp", feature = "udp"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "tcp", feature = "udp"))))]
$item
)*
}
}
/// Feature `tcp` enabled.
macro_rules! cfg_tcp {
($($item:item)*) => {
$(
#[cfg(feature = "tcp")]
#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
$item
)*
}
}
/// Feature `udp` enabled.
macro_rules! cfg_udp {
($($item:item)*) => {
$(
#[cfg(feature = "udp")]
#[cfg_attr(docsrs, doc(cfg(feature = "udp")))]
$item
)*
}
}
/// Feature `uds` enabled.
#[cfg(unix)]
macro_rules! cfg_uds {
($($item:item)*) => {
$(
#[cfg(feature = "uds")]
#[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
$item
)*
}
}
/// Feature `pipe` enabled.
#[cfg(unix)]
macro_rules! cfg_pipe {
($($item:item)*) => {
$(
#[cfg(feature = "pipe")]
#[cfg_attr(docsrs, doc(cfg(feature = "pipe")))]
$item
)*
}
}
/// Feature `os-util` enabled, or one of the features that need `os-util`.
#[cfg(unix)]
macro_rules! cfg_any_os_util {
($($item:item)*) => {
$(
#[cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "uds", feature = "pipe"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "uds", feature = "pipe"))))]
$item
)*
}
}
/// Feature `os-util` enabled, or one of the features that need `os-util`.
#[cfg(windows)]
macro_rules! cfg_any_os_util {
($($item:item)*) => {
$(
#[cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "pipe"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "pipe"))))]
$item
)*
}
}