File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,19 @@ impl<T: std::io::Read + ?Sized> embedded_io::Read for FromStd<T> {
4040 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
4141 self . inner . read ( buf)
4242 }
43+
44+ fn read_exact (
45+ & mut self ,
46+ buf : & mut [ u8 ] ,
47+ ) -> Result < ( ) , embedded_io:: ReadExactError < Self :: Error > > {
48+ match self . inner . read_exact ( buf) {
49+ Ok ( ( ) ) => Ok ( ( ) ) ,
50+ Err ( error) if error. kind ( ) == std:: io:: ErrorKind :: UnexpectedEof => {
51+ Err ( embedded_io:: ReadExactError :: UnexpectedEof )
52+ }
53+ Err ( error) => Err ( error. into ( ) ) ,
54+ }
55+ }
4356}
4457
4558impl < T : std:: io:: BufRead + ?Sized > embedded_io:: BufRead for FromStd < T > {
@@ -125,6 +138,17 @@ impl<T: embedded_io::Read + ?Sized> std::io::Read for ToStd<T> {
125138 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , std:: io:: Error > {
126139 self . inner . read ( buf) . map_err ( to_std_error)
127140 }
141+
142+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < ( ) > {
143+ match self . inner . read_exact ( buf) {
144+ Ok ( ( ) ) => Ok ( ( ) ) ,
145+ Err ( e @ embedded_io:: ReadExactError :: UnexpectedEof ) => Err ( std:: io:: Error :: new (
146+ std:: io:: ErrorKind :: UnexpectedEof ,
147+ format ! ( "{e:?}" ) ,
148+ ) ) ,
149+ Err ( embedded_io:: ReadExactError :: Other ( e) ) => Err ( to_std_error ( e) ) ,
150+ }
151+ }
128152}
129153
130154impl < T : embedded_io:: Write + ?Sized > std:: io:: Write for ToStd < T > {
You can’t perform that action at this time.
0 commit comments