]> git.proxmox.com Git - rustc.git/blob - library/std/src/sys/wasi/ext/mod.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / library / std / src / sys / wasi / ext / mod.rs
1 //! Platform-specific extensions to `std` for WASI.
2 //!
3 //! Provides access to platform-level information on WASI, and exposes
4 //! WASI-specific functions that would otherwise be inappropriate as
5 //! part of the core `std` library.
6 //!
7 //! It exposes more ways to deal with platform-specific strings (`OsStr`,
8 //! `OsString`), allows to set permissions more granularly, extract low-level
9 //! file descriptors from files and sockets, and has platform-specific helpers
10 //! for spawning processes.
11 //!
12 //! # Examples
13 //!
14 //! ```no_run
15 //! use std::fs::File;
16 //! use std::os::wasi::prelude::*;
17 //!
18 //! fn main() -> std::io::Result<()> {
19 //! let f = File::create("foo.txt")?;
20 //! let fd = f.as_raw_fd();
21 //!
22 //! // use fd with native WASI bindings
23 //!
24 //! Ok(())
25 //! }
26 //! ```
27
28 #![deny(unsafe_op_in_unsafe_fn)]
29 #![doc(cfg(target_os = "wasi"))]
30
31 pub mod ffi;
32 pub mod fs;
33 pub mod io;
34
35 /// A prelude for conveniently writing platform-specific code.
36 ///
37 /// Includes all extension traits, and some important type definitions.
38 #[stable(feature = "rust1", since = "1.0.0")]
39 pub mod prelude {
40 #[doc(no_inline)]
41 #[stable(feature = "rust1", since = "1.0.0")]
42 pub use super::ffi::{OsStrExt, OsStringExt};
43 #[doc(no_inline)]
44 #[stable(feature = "rust1", since = "1.0.0")]
45 pub use super::fs::FileTypeExt;
46 #[doc(no_inline)]
47 #[stable(feature = "rust1", since = "1.0.0")]
48 pub use super::fs::{DirEntryExt, FileExt, MetadataExt, OpenOptionsExt};
49 #[doc(no_inline)]
50 #[stable(feature = "rust1", since = "1.0.0")]
51 pub use super::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
52 }