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 > {
@@ -105,6 +118,17 @@ impl<T: embedded_io::Read + ?Sized> std::io::Read for ToStd<T> {
105118 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , std:: io:: Error > {
106119 self . inner . read ( buf) . map_err ( to_std_error)
107120 }
121+
122+ fn read_exact ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < ( ) > {
123+ match self . inner . read_exact ( buf) {
124+ Ok ( ( ) ) => Ok ( ( ) ) ,
125+ Err ( e @ embedded_io:: ReadExactError :: UnexpectedEof ) => Err ( std:: io:: Error :: new (
126+ std:: io:: ErrorKind :: UnexpectedEof ,
127+ format ! ( "{e:?}" ) ,
128+ ) ) ,
129+ Err ( embedded_io:: ReadExactError :: Other ( e) ) => Err ( to_std_error ( e) ) ,
130+ }
131+ }
108132}
109133
110134impl < T : embedded_io:: Write + ?Sized > std:: io:: Write for ToStd < T > {
You can’t perform that action at this time.
0 commit comments