1- //! Serial interface
1+ //! Serial interface.
22
3- /// Serial error
3+ /// Serial error.
44pub trait Error : core:: fmt:: Debug {
55 /// Convert error to a generic serial error kind
66 ///
@@ -11,12 +11,13 @@ pub trait Error: core::fmt::Debug {
1111}
1212
1313impl Error for core:: convert:: Infallible {
14+ #[ inline]
1415 fn kind ( & self ) -> ErrorKind {
1516 match * self { }
1617 }
1718}
1819
19- /// Serial error kind
20+ /// Serial error kind.
2021///
2122/// This represents a common set of serial operation errors. HAL implementations are
2223/// free to define more specific or additional error types. However, by providing
@@ -38,12 +39,14 @@ pub enum ErrorKind {
3839}
3940
4041impl Error for ErrorKind {
42+ #[ inline]
4143 fn kind ( & self ) -> ErrorKind {
4244 * self
4345 }
4446}
4547
4648impl core:: fmt:: Display for ErrorKind {
49+ #[ inline]
4750 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
4851 match self {
4952 Self :: Overrun => write ! ( f, "The peripheral receive buffer was overrun" ) ,
@@ -61,7 +64,7 @@ impl core::fmt::Display for ErrorKind {
6164 }
6265}
6366
64- /// Serial error type trait
67+ /// Serial error type trait.
6568///
6669/// This just defines the error type, to be used by the other traits.
6770pub trait ErrorType {
@@ -73,7 +76,7 @@ impl<T: ErrorType + ?Sized> ErrorType for &mut T {
7376 type Error = T :: Error ;
7477}
7578
76- /// Read half of a serial interface
79+ /// Read half of a serial interface.
7780///
7881/// Some serial interfaces support different data sizes (8 bits, 9 bits, etc.);
7982/// This can be encoded in this trait via the `Word` type parameter.
@@ -83,25 +86,28 @@ pub trait Read<Word: Copy = u8>: ErrorType {
8386}
8487
8588impl < T : Read < Word > + ?Sized , Word : Copy > Read < Word > for & mut T {
89+ #[ inline]
8690 fn read ( & mut self ) -> nb:: Result < Word , Self :: Error > {
8791 T :: read ( self )
8892 }
8993}
9094
91- /// Write half of a serial interface
95+ /// Write half of a serial interface.
9296pub trait Write < Word : Copy = u8 > : ErrorType {
93- /// Writes a single word to the serial interface
97+ /// Writes a single word to the serial interface.
9498 fn write ( & mut self , word : Word ) -> nb:: Result < ( ) , Self :: Error > ;
9599
96- /// Ensures that none of the previously written words are still buffered
100+ /// Ensures that none of the previously written words are still buffered.
97101 fn flush ( & mut self ) -> nb:: Result < ( ) , Self :: Error > ;
98102}
99103
100104impl < T : Write < Word > + ?Sized , Word : Copy > Write < Word > for & mut T {
105+ #[ inline]
101106 fn write ( & mut self , word : Word ) -> nb:: Result < ( ) , Self :: Error > {
102107 T :: write ( self , word)
103108 }
104109
110+ #[ inline]
105111 fn flush ( & mut self ) -> nb:: Result < ( ) , Self :: Error > {
106112 T :: flush ( self )
107113 }
@@ -115,6 +121,7 @@ impl<Word, Error: self::Error> core::fmt::Write for dyn Write<Word, Error = Erro
115121where
116122 Word : Copy + From < u8 > ,
117123{
124+ #[ inline]
118125 fn write_str ( & mut self , s : & str ) -> core:: fmt:: Result {
119126 let _ = s
120127 . bytes ( )
0 commit comments