File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,20 @@ impl Read for StdinRaw {
120
120
fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
121
121
handle_ebadf ( self . 0 . read_to_string ( buf) , 0 )
122
122
}
123
+
124
+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < ( ) > {
125
+ if buf. is_empty ( ) {
126
+ return Ok ( ( ) ) ;
127
+ }
128
+ handle_ebadf_err ( self . 0 . read_exact ( buf) , io:: Error :: READ_EXACT_EOF )
129
+ }
130
+
131
+ fn read_buf_exact ( & mut self , buf : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
132
+ if buf. capacity ( ) == 0 {
133
+ return Ok ( ( ) ) ;
134
+ }
135
+ handle_ebadf_err ( self . 0 . read_buf_exact ( buf) , io:: Error :: READ_EXACT_EOF )
136
+ }
123
137
}
124
138
125
139
impl Write for StdoutRaw {
@@ -200,6 +214,13 @@ fn handle_ebadf_lazy<T>(r: io::Result<T>, default: impl FnOnce() -> T) -> io::Re
200
214
}
201
215
}
202
216
217
+ fn handle_ebadf_err < T > ( r : io:: Result < T > , default_err : io:: Error ) -> io:: Result < T > {
218
+ match r {
219
+ Err ( ref e) if stdio:: is_ebadf ( e) => Err ( default_err) ,
220
+ r => r,
221
+ }
222
+ }
223
+
203
224
/// A handle to the standard input stream of a process.
204
225
///
205
226
/// Each handle is a shared reference to a global buffer of input data to this
You can’t perform that action at this time.
0 commit comments