| 1 | //! Serial interface |
| 2 | |
| 3 | use nb; |
| 4 | |
| 5 | /// Read half of a serial interface |
| 6 | /// |
| 7 | /// Some serial interfaces support different data sizes (8 bits, 9 bits, etc.); |
| 8 | /// This can be encoded in this trait via the `Word` type parameter. |
| 9 | pub trait Read<Word> { |
| 10 | /// Read error |
| 11 | type Error; |
| 12 | |
| 13 | /// Reads a single word from the serial interface |
| 14 | fn read(&mut self) -> nb::Result<Word, Self::Error>; |
| 15 | } |
| 16 | |
| 17 | /// Write half of a serial interface |
| 18 | pub trait Write<Word> { |
| 19 | /// Write error |
| 20 | type Error; |
| 21 | |
| 22 | /// Writes a single word to the serial interface |
| 23 | fn write(&mut self, word: Word) -> nb::Result<(), Self::Error>; |
| 24 | |
| 25 | /// Ensures that none of the previously written words are still buffered |
| 26 | fn flush(&mut self) -> nb::Result<(), Self::Error>; |
| 27 | } |
| 28 | |