Skip to main content

std/os/windows/
mod.rs

1//! Platform-specific extensions to `std` for Windows.
2//!
3//! Provides access to platform-level information for Windows, and exposes
4//! Windows-specific idioms that would otherwise be inappropriate as part
5//! the core `std` library. These extensions allow developers to use
6//! `std` types and idioms with Windows in a way that the normal
7//! platform-agnostic idioms would not normally support.
8//!
9//! # Examples
10//!
11#![cfg_attr(windows, doc = "```no_run")]
12#![cfg_attr(not(windows), doc = "```ignore (needs windows)")]
13//! use std::fs::File;
14//! use std::os::windows::prelude::*;
15//!
16//! fn main() -> std::io::Result<()> {
17//!     let f = File::create("foo.txt")?;
18//!     let handle = f.as_raw_handle();
19//!
20//!     // use handle with native windows bindings
21//!
22//!     Ok(())
23//! }
24//! ```
25
26#![stable(feature = "rust1", since = "1.0.0")]
27#![doc(cfg(windows))]
28#![deny(unsafe_op_in_unsafe_fn)]
29
30pub mod ffi;
31pub mod fs;
32pub mod io;
33#[unstable(feature = "windows_unix_domain_sockets", issue = "150487")]
34pub mod net;
35pub mod process;
36pub mod raw;
37pub mod thread;
38
39/// A prelude for conveniently writing platform-specific code.
40///
41/// Includes all extension traits, and some important type definitions.
42#[stable(feature = "rust1", since = "1.0.0")]
43pub mod prelude {
44    #[doc(no_inline)]
45    #[stable(feature = "rust1", since = "1.0.0")]
46    pub use super::ffi::{OsStrExt, OsStringExt};
47    #[doc(no_inline)]
48    #[stable(feature = "file_offset", since = "1.15.0")]
49    pub use super::fs::FileExt;
50    #[doc(no_inline)]
51    #[stable(feature = "rust1", since = "1.0.0")]
52    pub use super::fs::{MetadataExt, OpenOptionsExt};
53    #[doc(no_inline)]
54    #[stable(feature = "rust1", since = "1.0.0")]
55    pub use super::io::{
56        AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, FromRawHandle, FromRawSocket,
57        HandleOrInvalid, IntoRawHandle, IntoRawSocket, OwnedHandle, OwnedSocket,
58    };
59    #[doc(no_inline)]
60    #[stable(feature = "rust1", since = "1.0.0")]
61    pub use super::io::{AsRawHandle, AsRawSocket, RawHandle, RawSocket};
62}