Skip to content

Commit f5017fa

Browse files
committed
Add os-ext feature
Deprecating the pipe and os-util features.
1 parent cf826bf commit f5017fa

File tree

10 files changed

+53
-65
lines changed

10 files changed

+53
-65
lines changed

Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ include = [
3030
# By default Mio only provides a shell implementation.
3131
default = []
3232

33+
# Enables the `Poll` and `Registry` types.
3334
os-poll = []
34-
os-util = []
35-
pipe = ["os-poll"]
35+
# Enables additional OS specific extensions, e.g. Unix `pipe(2)`.
36+
os-ext = ["os-poll"]
3637
# Enables `mio::net` module containing networking primitives.
3738
net = []
3839

@@ -41,6 +42,8 @@ extra-docs = [] # Docs are now always present.
4142
tcp = ["net"] # Replaced with "net" feature.
4243
udp = ["net"] # Replaced with "net" feature.
4344
uds = ["net"] # Replaced with "net" feature.
45+
pipe = ["os-ext"] # Replaced with "os-ext" feature.
46+
os-util = ["os-ext"]# Replaced with "os-ext" feature.
4447

4548
[dependencies]
4649
log = "0.4.8"

src/lib.rs

+16-31
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,28 @@ pub use poll::{Poll, Registry};
6868
pub use token::Token;
6969
pub use waker::Waker;
7070

71-
#[cfg(all(unix, any(feature = "os-util", feature = "pipe")))]
72-
#[cfg_attr(
73-
docsrs,
74-
doc(cfg(all(unix, any(feature = "os-util", feature = "pipe"))))
75-
)]
71+
#[cfg(all(unix, feature = "os-ext"))]
72+
#[cfg_attr(docsrs, doc(cfg(all(unix, feature = "os-ext"))))]
7673
pub mod unix {
7774
//! Unix only extensions.
7875
79-
#[cfg(feature = "os-util")]
80-
#[cfg_attr(docsrs, doc(cfg(all(unix, feature = "os-util"))))]
81-
pub use crate::sys::SourceFd;
82-
83-
cfg_pipe! {
84-
pub mod pipe {
85-
//! Unix pipe.
86-
//!
87-
//! See the [`new`] function for documentation.
76+
pub mod pipe {
77+
//! Unix pipe.
78+
//!
79+
//! See the [`new`] function for documentation.
8880
89-
pub use crate::sys::pipe::{new, Receiver, Sender};
90-
}
81+
pub use crate::sys::pipe::{new, Receiver, Sender};
9182
}
83+
84+
pub use crate::sys::SourceFd;
9285
}
9386

94-
#[cfg(all(windows, feature = "os-util"))]
95-
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "os-util"))))]
87+
#[cfg(all(windows, feature = "os-ext"))]
88+
#[cfg_attr(docsrs, doc(cfg(all(windows, feature = "os-ext"))))]
9689
pub mod windows {
9790
//! Windows only extensions.
9891
99-
cfg_os_poll! {
100-
pub use crate::sys::named_pipe::NamedPipe;
101-
}
92+
pub use crate::sys::named_pipe::NamedPipe;
10293
}
10394

10495
pub mod features {
@@ -115,17 +106,11 @@ pub mod features {
115106
//!
116107
//! This makes `Poll`, `Registry` and `Waker` functional.
117108
//!
118-
#![cfg_attr(feature = "os-util", doc = "## `os-util` (enabled)")]
119-
#![cfg_attr(not(feature = "os-util"), doc = "## `os-util` (disabled)")]
120-
//!
121-
//! `os-util` enables additional OS specific facilities. Currently this
122-
//! means the `unix` module (with `SourceFd`) becomes available.
123-
//!
124-
#![cfg_attr(feature = "pipe", doc = "## `pipe` (enabled)")]
125-
#![cfg_attr(not(feature = "pipe"), doc = "## `pipe` (disabled)")]
109+
#![cfg_attr(feature = "os-ext", doc = "## `os-ext` (enabled)")]
110+
#![cfg_attr(not(feature = "os-ext"), doc = "## `os-ext` (disabled)")]
126111
//!
127-
//! The `pipe` feature adds `unix::pipe`, and related types, a non-blocking
128-
//! wrapper around the `pipe(2)` system call.
112+
//! `os-ext` enables additional OS specific facilities. These facilities can
113+
//! be found in the `unix` and `windows` module.
129114
//!
130115
#![cfg_attr(feature = "net", doc = "## Network types (enabled)")]
131116
#![cfg_attr(not(feature = "net"), doc = "## Network types (disabled)")]

src/macros.rs

+19-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Depending on the features not all macros are used.
44
#![allow(unused_macros)]
55

6-
/// Feature `os-poll` enabled.
6+
/// The `os-poll` feature is enabled.
77
macro_rules! cfg_os_poll {
88
($($item:item)*) => {
99
$(
@@ -14,7 +14,7 @@ macro_rules! cfg_os_poll {
1414
}
1515
}
1616

17-
/// Feature `os-poll` disabled.
17+
/// The `os-poll` feature is disabled.
1818
macro_rules! cfg_not_os_poll {
1919
($($item:item)*) => {
2020
$(
@@ -24,47 +24,46 @@ macro_rules! cfg_not_os_poll {
2424
}
2525
}
2626

27-
/// The `net` feature is enabled.
28-
macro_rules! cfg_net {
27+
/// The `os-ext` feature is enabled.
28+
macro_rules! cfg_os_ext {
2929
($($item:item)*) => {
3030
$(
31-
#[cfg(feature = "net")]
32-
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
31+
#[cfg(feature = "os-ext")]
32+
#[cfg_attr(docsrs, doc(cfg(feature = "os-ext")))]
3333
$item
3434
)*
3535
}
3636
}
3737

38-
/// One of the features enabled that needs `IoSource`. That is `net` or `pipe`
39-
/// (on Unix).
40-
macro_rules! cfg_io_source {
38+
/// The `net` feature is enabled.
39+
macro_rules! cfg_net {
4140
($($item:item)*) => {
4241
$(
43-
#[cfg(any(feature = "net", all(unix, feature = "pipe")))]
44-
#[cfg_attr(docsrs, doc(any(feature = "net", all(unix, feature = "pipe"))))]
42+
#[cfg(feature = "net")]
43+
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
4544
$item
4645
)*
4746
}
4847
}
4948

50-
/// Feature `pipe` enabled.
51-
#[cfg(unix)]
52-
macro_rules! cfg_pipe {
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 {
5352
($($item:item)*) => {
5453
$(
55-
#[cfg(feature = "pipe")]
56-
#[cfg_attr(docsrs, doc(cfg(feature = "pipe")))]
54+
#[cfg(any(feature = "net", all(unix, feature = "os-ext")))]
55+
#[cfg_attr(docsrs, doc(any(feature = "net", all(unix, feature = "os-ext"))))]
5756
$item
5857
)*
5958
}
6059
}
6160

62-
/// Feature `os-util` enabled, or one of the features that need `os-util`.
63-
macro_rules! cfg_any_os_util {
61+
/// The `os-ext` feature is enabled, or one of the features that need `os-ext`.
62+
macro_rules! cfg_any_os_ext {
6463
($($item:item)*) => {
6564
$(
66-
#[cfg(any(feature = "os-util", feature = "net", all(unix, feature = "pipe")))]
67-
#[cfg_attr(docsrs, doc(cfg(any(feature = "os-util", feature = "net", all(unix, feature = "pipe")))))]
65+
#[cfg(any(feature = "os-ext", feature = "net"))]
66+
#[cfg_attr(docsrs, doc(cfg(any(feature = "os-ext", feature = "net"))))]
6867
$item
6968
)*
7069
}

src/sys/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cfg_not_os_poll! {
6868
pub(crate) use self::shell::*;
6969

7070
#[cfg(unix)]
71-
cfg_any_os_util! {
71+
cfg_any_os_ext! {
7272
mod unix;
7373
pub use self::unix::SourceFd;
7474
}

src/sys/shell/selector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Selector {
2626
}
2727

2828
#[cfg(unix)]
29-
cfg_any_os_util! {
29+
cfg_any_os_ext! {
3030
use crate::{Interest, Token};
3131

3232
impl Selector {

src/sys/unix/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cfg_os_poll! {
5454
}
5555
}
5656

57-
cfg_pipe! {
57+
cfg_os_ext! {
5858
pub(crate) mod pipe;
5959
}
6060
}
@@ -65,7 +65,7 @@ cfg_not_os_poll! {
6565
pub use self::uds::SocketAddr;
6666
}
6767

68-
cfg_any_os_util! {
68+
cfg_any_os_ext! {
6969
mod sourcefd;
7070
pub use self::sourcefd::SourceFd;
7171
}

src/sys/windows/event.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Event {
2626
self.flags |= afd::POLL_RECEIVE
2727
}
2828

29-
#[cfg(feature = "os-util")]
29+
#[cfg(feature = "os-ext")]
3030
pub(super) fn set_writable(&mut self) {
3131
self.flags |= afd::POLL_SEND;
3232
}

src/sys/windows/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ cfg_net! {
3232
pub(crate) mod udp;
3333
}
3434

35-
#[cfg(feature = "os-util")]
36-
pub(crate) mod named_pipe;
35+
cfg_os_ext! {
36+
pub(crate) mod named_pipe;
37+
}
3738

3839
mod waker;
3940
pub(crate) use waker::Waker;

src/sys/windows/overlapped.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use crate::sys::windows::Event;
33
use std::cell::UnsafeCell;
44
use std::fmt;
55

6-
use winapi::um::minwinbase::OVERLAPPED_ENTRY;
7-
#[cfg(feature = "os-util")]
6+
#[cfg(feature = "os-ext")]
87
use winapi::um::minwinbase::OVERLAPPED;
8+
use winapi::um::minwinbase::OVERLAPPED_ENTRY;
99

1010
#[repr(C)]
1111
pub(crate) struct Overlapped {
1212
inner: UnsafeCell<miow::Overlapped>,
1313
pub(crate) callback: fn(&OVERLAPPED_ENTRY, Option<&mut Vec<Event>>),
1414
}
1515

16-
#[cfg(feature = "os-util")]
16+
#[cfg(feature = "os-ext")]
1717
impl Overlapped {
1818
pub(crate) fn new(cb: fn(&OVERLAPPED_ENTRY, Option<&mut Vec<Event>>)) -> Overlapped {
1919
Overlapped {

src/sys/windows/selector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl Selector {
374374
self.inner.cp.clone()
375375
}
376376

377-
#[cfg(feature = "os-util")]
377+
#[cfg(feature = "os-ext")]
378378
pub(super) fn same_port(&self, other: &Arc<CompletionPort>) -> bool {
379379
Arc::ptr_eq(&self.inner.cp, other)
380380
}
@@ -749,4 +749,4 @@ cfg_net! {
749749

750750
flags
751751
}
752-
}
752+
}

0 commit comments

Comments
 (0)