1
1
use super :: SerialPort ;
2
+ use core:: borrow:: BorrowMut ;
2
3
use usb_device:: bus:: UsbBus ;
3
4
4
5
#[ derive( Debug ) ]
@@ -22,11 +23,15 @@ impl embedded_io::Error for Error {
22
23
}
23
24
}
24
25
25
- impl < Bus : UsbBus > embedded_io:: ErrorType for SerialPort < ' _ , Bus > {
26
+ impl < Bus : UsbBus , RS : BorrowMut < [ u8 ] > , WS : BorrowMut < [ u8 ] > > embedded_io:: ErrorType
27
+ for SerialPort < ' _ , Bus , RS , WS >
28
+ {
26
29
type Error = Error ;
27
30
}
28
31
29
- impl < Bus : UsbBus > embedded_io:: Read for SerialPort < ' _ , Bus > {
32
+ impl < Bus : UsbBus , RS : BorrowMut < [ u8 ] > , WS : BorrowMut < [ u8 ] > > embedded_io:: Read
33
+ for SerialPort < ' _ , Bus , RS , WS >
34
+ {
30
35
fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
31
36
loop {
32
37
match self . read ( buf) . map_err ( From :: from) {
@@ -40,14 +45,18 @@ impl<Bus: UsbBus> embedded_io::Read for SerialPort<'_, Bus> {
40
45
}
41
46
}
42
47
43
- impl < Bus : UsbBus > embedded_io:: ReadReady for SerialPort < ' _ , Bus > {
48
+ impl < Bus : UsbBus , RS : BorrowMut < [ u8 ] > , WS : BorrowMut < [ u8 ] > > embedded_io:: ReadReady
49
+ for SerialPort < ' _ , Bus , RS , WS >
50
+ {
44
51
fn read_ready ( & mut self ) -> Result < bool , Self :: Error > {
45
52
self . poll ( ) ?;
46
53
Ok ( self . read_buf . available_read ( ) != 0 )
47
54
}
48
55
}
49
56
50
- impl < Bus : UsbBus > embedded_io:: Write for SerialPort < ' _ , Bus > {
57
+ impl < Bus : UsbBus , RS : BorrowMut < [ u8 ] > , WS : BorrowMut < [ u8 ] > > embedded_io:: Write
58
+ for SerialPort < ' _ , Bus , RS , WS >
59
+ {
51
60
fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize , Self :: Error > {
52
61
if buf. is_empty ( ) {
53
62
return Ok ( 0 ) ;
@@ -69,7 +78,9 @@ impl<Bus: UsbBus> embedded_io::Write for SerialPort<'_, Bus> {
69
78
}
70
79
}
71
80
72
- impl < Bus : UsbBus > embedded_io:: WriteReady for SerialPort < ' _ , Bus > {
81
+ impl < Bus : UsbBus , RS : BorrowMut < [ u8 ] > , WS : BorrowMut < [ u8 ] > > embedded_io:: WriteReady
82
+ for SerialPort < ' _ , Bus , RS , WS >
83
+ {
73
84
fn write_ready ( & mut self ) -> Result < bool , Self :: Error > {
74
85
Ok ( self . write_buf . available_write ( ) != 0 )
75
86
}
0 commit comments