1- use crate :: io;
1+ use crate :: fmt;
2+ use crate :: io:: { self , BorrowedCursor , IoSlice , IoSliceMut } ;
23
34pub struct Stdin ;
45pub struct Stdout ;
@@ -11,9 +12,47 @@ impl Stdin {
1112}
1213
1314impl io:: Read for Stdin {
15+ #[ inline]
1416 fn read ( & mut self , _buf : & mut [ u8 ] ) -> io:: Result < usize > {
1517 Ok ( 0 )
1618 }
19+
20+ #[ inline]
21+ fn read_buf ( & mut self , _cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
22+ Ok ( ( ) )
23+ }
24+
25+ #[ inline]
26+ fn read_vectored ( & mut self , _bufs : & mut [ IoSliceMut < ' _ > ] ) -> io:: Result < usize > {
27+ Ok ( 0 )
28+ }
29+
30+ #[ inline]
31+ fn is_read_vectored ( & self ) -> bool {
32+ // Do not force `Chain<Empty, T>` or `Chain<T, Empty>` to use vectored
33+ // reads, unless the other reader is vectored.
34+ false
35+ }
36+
37+ #[ inline]
38+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> io:: Result < ( ) > {
39+ if !buf. is_empty ( ) { Err ( io:: Error :: READ_EXACT_EOF ) } else { Ok ( ( ) ) }
40+ }
41+
42+ #[ inline]
43+ fn read_buf_exact ( & mut self , cursor : BorrowedCursor < ' _ > ) -> io:: Result < ( ) > {
44+ if cursor. capacity ( ) != 0 { Err ( io:: Error :: READ_EXACT_EOF ) } else { Ok ( ( ) ) }
45+ }
46+
47+ #[ inline]
48+ fn read_to_end ( & mut self , _buf : & mut Vec < u8 > ) -> io:: Result < usize > {
49+ Ok ( 0 )
50+ }
51+
52+ #[ inline]
53+ fn read_to_string ( & mut self , _buf : & mut String ) -> io:: Result < usize > {
54+ Ok ( 0 )
55+ }
1756}
1857
1958impl Stdout {
@@ -23,10 +62,38 @@ impl Stdout {
2362}
2463
2564impl io:: Write for Stdout {
65+ #[ inline]
2666 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
2767 Ok ( buf. len ( ) )
2868 }
2969
70+ #[ inline]
71+ fn write_vectored ( & mut self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
72+ let total_len = bufs. iter ( ) . map ( |b| b. len ( ) ) . sum ( ) ;
73+ Ok ( total_len)
74+ }
75+
76+ #[ inline]
77+ fn is_write_vectored ( & self ) -> bool {
78+ true
79+ }
80+
81+ #[ inline]
82+ fn write_all ( & mut self , _buf : & [ u8 ] ) -> io:: Result < ( ) > {
83+ Ok ( ( ) )
84+ }
85+
86+ #[ inline]
87+ fn write_all_vectored ( & mut self , _bufs : & mut [ IoSlice < ' _ > ] ) -> io:: Result < ( ) > {
88+ Ok ( ( ) )
89+ }
90+
91+ #[ inline]
92+ fn write_fmt ( & mut self , _args : fmt:: Arguments < ' _ > ) -> io:: Result < ( ) > {
93+ Ok ( ( ) )
94+ }
95+
96+ #[ inline]
3097 fn flush ( & mut self ) -> io:: Result < ( ) > {
3198 Ok ( ( ) )
3299 }
0 commit comments