Skip to content

Commit

Permalink
net: replace winapi with windows-sys (#5204)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Nov 22, 2022
1 parent e143073 commit 299bd6a
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 233 deletions.
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Expand Up @@ -24,8 +24,8 @@ httpdate = "1.0"
once_cell = "1.5.2"
rand = "0.8.3"

[target.'cfg(windows)'.dev-dependencies.winapi]
version = "0.3.8"
[target.'cfg(windows)'.dev-dependencies.windows-sys]
version = "0.42.0"

[[example]]
name = "chat"
Expand Down
4 changes: 2 additions & 2 deletions examples/named-pipe-multi-client.rs
Expand Up @@ -6,7 +6,7 @@ async fn windows_main() -> io::Result<()> {
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::windows::named_pipe::{ClientOptions, ServerOptions};
use tokio::time;
use winapi::shared::winerror;
use windows_sys::Win32::Foundation::ERROR_PIPE_BUSY;

const PIPE_NAME: &str = r"\\.\pipe\named-pipe-multi-client";
const N: usize = 10;
Expand Down Expand Up @@ -59,7 +59,7 @@ async fn windows_main() -> io::Result<()> {
let mut client = loop {
match ClientOptions::new().open(PIPE_NAME) {
Ok(client) => break client,
Err(e) if e.raw_os_error() == Some(winerror::ERROR_PIPE_BUSY as i32) => (),
Err(e) if e.raw_os_error() == Some(ERROR_PIPE_BUSY as i32) => (),
Err(e) => return Err(e),
}

Expand Down
40 changes: 19 additions & 21 deletions tokio/Cargo.toml
Expand Up @@ -52,14 +52,11 @@ net = [
"mio/os-ext",
"mio/net",
"socket2",
"winapi/fileapi",
"winapi/handleapi",
"winapi/namedpipeapi",
"winapi/winbase",
"winapi/winnt",
"winapi/minwindef",
"winapi/accctrl",
"winapi/aclapi",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_Security",
"windows-sys/Win32_Storage_FileSystem",
"windows-sys/Win32_System_Pipes",
"windows-sys/Win32_System_SystemServices",
]
process = [
"bytes",
Expand All @@ -68,12 +65,9 @@ process = [
"mio/os-ext",
"mio/net",
"signal-hook-registry",
"winapi/handleapi",
"winapi/minwindef",
"winapi/processthreadsapi",
"winapi/threadpoollegacyapiset",
"winapi/winbase",
"winapi/winnt",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Threading",
"windows-sys/Win32_System_WindowsProgramming",
]
# Includes basic task execution capabilities
rt = []
Expand All @@ -87,9 +81,8 @@ signal = [
"mio/net",
"mio/os-ext",
"signal-hook-registry",
"winapi/consoleapi",
"winapi/wincon",
"winapi/minwindef",
"windows-sys/Win32_Foundation",
"windows-sys/Win32_System_Console",
]
sync = []
test-util = ["rt", "sync", "time"]
Expand Down Expand Up @@ -131,12 +124,17 @@ signal-hook-registry = { version = "1.1.1", optional = true }
libc = { version = "0.2.42" }
nix = { version = "0.24", default-features = false, features = ["fs", "socket"] }

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.8"
default-features = false
features = ["std"]
[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.42.0"
optional = true

[target.'cfg(docsrs)'.dependencies.windows-sys]
version = "0.42.0"
features = [
"Win32_Foundation",
"Win32_Security_Authorization",
]

[target.'cfg(windows)'.dev-dependencies.ntapi]
version = "0.3.6"

Expand Down
1 change: 0 additions & 1 deletion tokio/src/doc/mod.rs
Expand Up @@ -21,4 +21,3 @@
pub enum NotDefinedHere {}

pub mod os;
pub mod winapi;
66 changes: 0 additions & 66 deletions tokio/src/doc/winapi.rs

This file was deleted.

6 changes: 3 additions & 3 deletions tokio/src/fs/open_options.rs
Expand Up @@ -542,7 +542,7 @@ feature! {
/// # Examples
///
/// ```no_run
/// use winapi::um::winbase::FILE_FLAG_DELETE_ON_CLOSE;
/// use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_DELETE_ON_CLOSE;
/// use tokio::fs::OpenOptions;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -581,7 +581,7 @@ feature! {
/// # Examples
///
/// ```no_run
/// use winapi::um::winnt::FILE_ATTRIBUTE_HIDDEN;
/// use windows_sys::Win32::Storage::FileSystem::FILE_ATTRIBUTE_HIDDEN;
/// use tokio::fs::OpenOptions;
///
/// # #[tokio::main]
Expand Down Expand Up @@ -624,7 +624,7 @@ feature! {
/// # Examples
///
/// ```no_run
/// use winapi::um::winbase::SECURITY_IDENTIFICATION;
/// use windows_sys::Win32::Storage::FileSystem::SECURITY_IDENTIFICATION;
/// use tokio::fs::OpenOptions;
///
/// # #[tokio::main]
Expand Down
8 changes: 0 additions & 8 deletions tokio/src/lib.rs
Expand Up @@ -578,14 +578,6 @@ pub(crate) use self::doc::os;
#[allow(unused)]
pub(crate) use std::os;

#[cfg(docsrs)]
#[allow(unused)]
pub(crate) use self::doc::winapi;

#[cfg(all(not(docsrs), windows, feature = "net"))]
#[allow(unused)]
pub(crate) use winapi;

cfg_macros! {
/// Implementation detail of the `select!` macro. This macro is **not**
/// intended to be used as part of the public API and is permitted to
Expand Down

0 comments on commit 299bd6a

Please sign in to comment.