compio_fs/stdio/mod.rs
1cfg_if::cfg_if! {
2 if #[cfg(windows)] {
3 mod windows;
4 pub use windows::*;
5 } else if #[cfg(unix)] {
6 mod unix;
7 pub use unix::*;
8 }
9}
10
11/// Constructs a handle to the standard input of the current process.
12///
13/// ## Platform specific
14/// * Windows: This handle is best used for non-interactive uses, such as when a
15/// file is piped into the application. For technical reasons, if `stdin` is a
16/// console handle, the read method is implemented by using an ordinary
17/// blocking read on a separate thread, and it is impossible to cancel that
18/// read. This can make shutdown of the runtime hang until the user presses
19/// enter.
20///
21/// [`AsyncRead`]: compio_io::AsyncRead
22pub fn stdin() -> Stdin {
23 Stdin::new()
24}
25
26/// Constructs a handle to the standard output of the current process.
27///
28/// Concurrent writes to stdout must be executed with care: Only individual
29/// writes to this [`AsyncWrite`] are guaranteed to be intact. In particular
30/// you should be aware that writes using [`write_all`] are not guaranteed
31/// to occur as a single write, so multiple threads writing data with
32/// [`write_all`] may result in interleaved output.
33///
34/// [`AsyncWrite`]: compio_io::AsyncWrite
35/// [`write_all`]: compio_io::AsyncWriteExt::write_all
36pub fn stdout() -> Stdout {
37 Stdout::new()
38}
39
40/// Constructs a handle to the standard error of the current process.
41///
42/// Concurrent writes to stderr must be executed with care: Only individual
43/// writes to this [`AsyncWrite`] are guaranteed to be intact. In particular
44/// you should be aware that writes using [`write_all`] are not guaranteed
45/// to occur as a single write, so multiple threads writing data with
46/// [`write_all`] may result in interleaved output.
47///
48/// [`AsyncWrite`]: compio_io::AsyncWrite
49/// [`write_all`]: compio_io::AsyncWriteExt::write_all
50pub fn stderr() -> Stderr {
51 Stderr::new()
52}