File tree 3 files changed +55
-0
lines changed
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 15
15
use fs;
16
16
use net;
17
17
use sys;
18
+ use io;
18
19
use sys_common:: { self , AsInner , FromInner , IntoInner } ;
19
20
20
21
/// Raw file descriptors.
@@ -109,6 +110,21 @@ impl AsRawFd for net::UdpSocket {
109
110
}
110
111
}
111
112
113
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
114
+ impl AsRawFd for io:: Stdin {
115
+ fn as_raw_fd ( & self ) -> RawFd { 0 }
116
+ }
117
+
118
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
119
+ impl AsRawFd for io:: Stdout {
120
+ fn as_raw_fd ( & self ) -> RawFd { 1 }
121
+ }
122
+
123
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
124
+ impl AsRawFd for io:: Stderr {
125
+ fn as_raw_fd ( & self ) -> RawFd { 2 }
126
+ }
127
+
112
128
#[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
113
129
impl FromRawFd for net:: TcpStream {
114
130
unsafe fn from_raw_fd ( fd : RawFd ) -> net:: TcpStream {
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ use fs;
16
16
use net;
17
17
use os:: raw;
18
18
use sys;
19
+ use io;
19
20
use sys_common:: { self , AsInner , FromInner , IntoInner } ;
21
+ use libc;
20
22
21
23
/// Raw file descriptors.
22
24
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -104,6 +106,21 @@ impl AsRawFd for net::UdpSocket {
104
106
fn as_raw_fd ( & self ) -> RawFd { * self . as_inner ( ) . socket ( ) . as_inner ( ) }
105
107
}
106
108
109
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
110
+ impl AsRawFd for io:: Stdin {
111
+ fn as_raw_fd ( & self ) -> RawFd { libc:: STDIN_FILENO }
112
+ }
113
+
114
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
115
+ impl AsRawFd for io:: Stdout {
116
+ fn as_raw_fd ( & self ) -> RawFd { libc:: STDOUT_FILENO }
117
+ }
118
+
119
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
120
+ impl AsRawFd for io:: Stderr {
121
+ fn as_raw_fd ( & self ) -> RawFd { libc:: STDERR_FILENO }
122
+ }
123
+
107
124
#[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
108
125
impl FromRawFd for net:: TcpStream {
109
126
unsafe fn from_raw_fd ( fd : RawFd ) -> net:: TcpStream {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use os::windows::raw;
15
15
use net;
16
16
use sys_common:: { self , AsInner , FromInner , IntoInner } ;
17
17
use sys;
18
+ use io;
18
19
use sys:: c;
19
20
20
21
/// Raw HANDLEs.
@@ -71,6 +72,27 @@ impl AsRawHandle for fs::File {
71
72
}
72
73
}
73
74
75
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
76
+ impl AsRawHandle for io:: Stdin {
77
+ fn as_raw_handle ( & self ) -> RawHandle {
78
+ unsafe { c:: GetStdHandle ( c:: STD_INPUT_HANDLE ) as RawHandle }
79
+ }
80
+ }
81
+
82
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
83
+ impl AsRawHandle for io:: Stdout {
84
+ fn as_raw_handle ( & self ) -> RawHandle {
85
+ unsafe { c:: GetStdHandle ( c:: STD_OUTPUT_HANDLE ) as RawHandle }
86
+ }
87
+ }
88
+
89
+ #[ stable( feature = "asraw_stdio" , since = "1.21.0" ) ]
90
+ impl AsRawHandle for io:: Stderr {
91
+ fn as_raw_handle ( & self ) -> RawHandle {
92
+ unsafe { c:: GetStdHandle ( c:: STD_ERROR_HANDLE ) as RawHandle }
93
+ }
94
+ }
95
+
74
96
#[ stable( feature = "from_raw_os" , since = "1.1.0" ) ]
75
97
impl FromRawHandle for fs:: File {
76
98
unsafe fn from_raw_handle ( handle : RawHandle ) -> fs:: File {
You can’t perform that action at this time.
0 commit comments