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 /// Feature `os-poll` 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 /// Feature `os-poll` disabled.
18 macro_rules! cfg_not_os_poll {
fe_sq2(fe h,const fe f)19     ($($item:item)*) => {
20         $(
21             #[cfg(not(feature = "os-poll"))]
22             $item
23         )*
24     }
25 }
26 
27 /// One of the `tcp`, `udp`, `uds` features enabled.
28 #[cfg(unix)]
29 macro_rules! cfg_net {
30     ($($item:item)*) => {
31         $(
32             #[cfg(any(feature = "tcp", feature = "udp", feature = "uds"))]
33             #[cfg_attr(docsrs, doc(cfg(any(feature = "tcp", feature = "udp", feature = "uds"))))]
34             $item
35         )*
36     }
37 }
38 
39 /// One of the `tcp`, `udp` features enabled.
40 #[cfg(windows)]
41 macro_rules! cfg_net {
42     ($($item:item)*) => {
43         $(
44             #[cfg(any(feature = "tcp", feature = "udp"))]
45             #[cfg_attr(docsrs, doc(cfg(any(feature = "tcp", feature = "udp"))))]
46             $item
47         )*
48     }
49 }
50 
51 /// Feature `tcp` enabled.
52 macro_rules! cfg_tcp {
53     ($($item:item)*) => {
54         $(
55             #[cfg(feature = "tcp")]
56             #[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
57             $item
58         )*
59     }
60 }
61 
62 /// Feature `udp` enabled.
63 macro_rules! cfg_udp {
64     ($($item:item)*) => {
65         $(
66             #[cfg(feature = "udp")]
67             #[cfg_attr(docsrs, doc(cfg(feature = "udp")))]
68             $item
69         )*
70     }
71 }
72 
73 /// Feature `uds` enabled.
74 #[cfg(unix)]
75 macro_rules! cfg_uds {
76     ($($item:item)*) => {
77         $(
78             #[cfg(feature = "uds")]
79             #[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
80             $item
81         )*
82     }
83 }
84 
85 /// Feature `os-util` enabled, or one of the features that need `os-util`.
86 #[cfg(unix)]
87 macro_rules! cfg_any_os_util {
88     ($($item:item)*) => {
89         $(
90             #[cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "uds"))]
91             #[cfg_attr(docsrs, doc(cfg(any(feature = "os-util", feature = "tcp", feature = "udp", feature = "uds"))))]
92             $item
93         )*
94     }
95 }
96 
97 /// Feature `os-util` enabled, or one of the features that need `os-util`.
98 #[cfg(windows)]
99 macro_rules! cfg_any_os_util {
100     ($($item:item)*) => {
101         $(
102             #[cfg(any(feature = "os-util", feature = "tcp", feature = "udp"))]
103             #[cfg_attr(docsrs, doc(cfg(any(feature = "os-util", feature = "tcp", feature = "udp"))))]
104             $item
105         )*
106     }
107 }
108