File tree 3 files changed +12
-10
lines changed
3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change 1
- use std:: {
2
- io:: { BufWriter , Read } ,
3
- thread:: sleep,
4
- time:: Duration ,
5
- } ;
1
+ use std:: { io:: BufWriter , thread:: sleep, time:: Duration } ;
6
2
7
3
use binread:: { io:: Cursor , BinRead , BinReaderExt } ;
8
4
use bytemuck:: { Pod , Zeroable } ;
@@ -263,8 +259,7 @@ impl Connection {
263
259
pub ( crate ) fn read ( & mut self , len : usize ) -> Result < Option < Vec < u8 > > , Error > {
264
260
let mut tmp = Vec :: with_capacity ( 1024 ) ;
265
261
loop {
266
- self . decoder
267
- . decode ( self . serial . serial_port_mut ( ) as & mut dyn Read , & mut tmp) ?;
262
+ self . decoder . decode ( & mut self . serial , & mut tmp) ?;
268
263
if tmp. len ( ) >= len {
269
264
return Ok ( Some ( tmp) ) ;
270
265
}
Original file line number Diff line number Diff line change
1
+ use std:: io:: Read ;
2
+
1
3
use serialport:: SerialPort ;
2
4
3
5
#[ cfg( feature = "raspberry" ) ]
@@ -79,3 +81,11 @@ impl Interface {
79
81
self . serial_port . as_mut ( )
80
82
}
81
83
}
84
+
85
+ // Note(dbuga): this impl is necessary because using `dyn SerialPort` as `dyn Read`
86
+ // requires trait_upcasting which isn't stable yet.
87
+ impl Read for Interface {
88
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
89
+ self . serial_port . read ( buf)
90
+ }
91
+ }
Original file line number Diff line number Diff line change 1
- #![ feature( trait_upcasting) ]
2
- #![ allow( incomplete_features) ] // trait_upcasting
3
-
4
1
pub use chip:: Chip ;
5
2
pub use cli:: config:: Config ;
6
3
pub use elf:: { FlashFrequency , FlashMode } ;
You can’t perform that action at this time.
0 commit comments