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 11//! Implementation of [`Serial`](https://docs.rs/embedded-hal/0.2.1/embedded_hal/serial/index.html)
22
3- use hal:: serial:: Read ;
3+ use hal:: serial:: { Read , Write } ;
44use nb;
55use serial;
66
@@ -25,6 +25,25 @@ impl Read<u8> for Serial {
2525 }
2626}
2727
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+
2847#[ cfg( test) ]
2948mod test {
3049 use super :: * ;
You can’t perform that action at this time.
0 commit comments