Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to windows-sys #5204

Merged
merged 12 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
38 changes: 17 additions & 21 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ 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_Storage_FileSystem",
"windows-sys/Win32_System_Pipes",
"windows-sys/Win32_System_SystemServices",
kennykerr marked this conversation as resolved.
Show resolved Hide resolved
]
process = [
"bytes",
Expand All @@ -68,12 +64,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 +80,7 @@ signal = [
"mio/net",
"mio/os-ext",
"signal-hook-registry",
"winapi/consoleapi",
"winapi/wincon",
"winapi/minwindef",
"windows-sys/Win32_System_Console",
]
sync = []
test-util = ["rt", "sync", "time"]
Expand Down Expand Up @@ -131,12 +122,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(any(windows, docsrs))'.dependencies.windows-sys]
version = "0.42.0"
optional = true

[target.'cfg(windows)'.dev-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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading