1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Raw handles to the standard terminal pipes.

use std::fs::File;

#[cfg(target_family = "unix")]
#[path = "unix.rs"]
mod imp;

#[cfg(target_os = "windows")]
#[path = "windows.rs"]
mod imp;

/// Raw handle to the standard output in [`File`] form,all bytes written are displayed in the terminal.
/// 
/// # Safety
/// 
/// The ownership of the stdout it's effectively transferred to the returned [`File`],making unsafe using
/// macros as [`print!`], [`println!`] or anything else that prints to the standard output.
pub unsafe fn raw_stdout() -> File {
    imp::raw_stdout()
}

/// Raw handle to the standard error in [`File`] form,all bytes written are displayed in the terminal.
/// 
/// # Safety
/// 
/// The ownership of the stdout it's effectively transferred to the returned [`File`],making unsafe using
/// macros as [`eprint!`], [`eprintln!`] or anything else that prints to the standard error.
pub unsafe fn raw_stderr() -> File {
    imp::raw_stderr()
}

/// Raw handle to the standard input in [`File`] form,all bytes readed come from input in the terminal.
/// 
/// # Safety
/// 
/// The ownership of the stdin it's effectively transferred to the returned [`File`],making unsafe using
/// functions as [`io::stdin`] or anything that reads from the standard input.
pub unsafe fn raw_stdin() -> File {
    imp::raw_stdin()
}