1 //! Macros to ease conditional code based on enabled features. 2 3 // Depending on the features not all macros are used. 4 #![allow(unused_macros)] 5 6 /// The `os-poll` feature is enabled. 7 macro_rules! cfg_os_poll { 8 ($($item:item)*) => { 9 $( 10 #[cfg(feature = "os-poll")] 11 #[cfg_attr(docsrs, doc(cfg(feature = "os-poll")))] 12 $item 13 )* 14 } 15 } 16 17 /// The `os-poll` feature is disabled. 18 macro_rules! cfg_not_os_poll { 19 ($($item:item)*) => { 20 $( 21 #[cfg(not(feature = "os-poll"))] 22 $item 23 )* 24 } 25 } 26 27 /// The `os-ext` feature is enabled. 28 macro_rules! cfg_os_ext { 29 ($($item:item)*) => { 30 $( 31 #[cfg(feature = "os-ext")] 32 #[cfg_attr(docsrs, doc(cfg(feature = "os-ext")))] 33 $item 34 )* 35 } 36 } 37 38 /// The `net` feature is enabled. 39 macro_rules! cfg_net { 40 ($($item:item)*) => { 41 $( 42 #[cfg(feature = "net")] 43 #[cfg_attr(docsrs, doc(cfg(feature = "net")))] 44 $item 45 )* 46 } 47 } 48 49 /// One of the features enabled that needs `IoSource`. That is `net` or `os-ext` 50 /// on Unix (for `pipe`). 51 macro_rules! cfg_io_source { 52 ($($item:item)*) => { 53 $( 54 #[cfg(any(feature = "net", all(unix, feature = "os-ext")))] 55 #[cfg_attr(docsrs, doc(cfg(any(feature = "net", all(unix, feature = "os-ext")))))] 56 $item 57 )* 58 } 59 } 60 61 /// The `os-ext` feature is enabled, or one of the features that need `os-ext`. 62 macro_rules! cfg_any_os_ext { 63 ($($item:item)*) => { 64 $( 65 #[cfg(any(feature = "os-ext", feature = "net"))] 66 #[cfg_attr(docsrs, doc(cfg(any(feature = "os-ext", feature = "net"))))] 67 $item 68 )* 69 } 70 } 71