File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1
1
//! Implementation of [`Serial`](https://docs.rs/embedded-hal/0.2.1/embedded_hal/serial/index.html)
2
2
3
- use hal:: serial:: Read ;
3
+ use hal:: serial:: { Read , Write } ;
4
4
use nb;
5
5
use serial;
6
6
@@ -25,6 +25,25 @@ impl Read<u8> for Serial {
25
25
}
26
26
}
27
27
28
+ impl Write < u8 > for Serial {
29
+ type Error = serial:: Error ;
30
+
31
+ fn write ( & mut self , word : u8 ) -> nb:: Result < ( ) , Self :: Error > {
32
+ use std:: io:: Write ;
33
+ self . 0
34
+ . write ( & [ word] )
35
+ . map_err ( |err| nb:: Error :: Other ( Self :: Error :: from ( err) ) ) ?;
36
+ Ok ( ( ) )
37
+ }
38
+
39
+ fn flush ( & mut self ) -> nb:: Result < ( ) , Self :: Error > {
40
+ use std:: io:: Write ;
41
+ self . 0
42
+ . flush ( )
43
+ . map_err ( |err| nb:: Error :: Other ( Self :: Error :: from ( err) ) )
44
+ }
45
+ }
46
+
28
47
#[ cfg( test) ]
29
48
mod test {
30
49
use super :: * ;
You can’t perform that action at this time.
0 commit comments