Skip to content

Commit 1c50642

Browse files
committed
added core::fmt::Error implementation for uarte::Error
1 parent 24a8b09 commit 1c50642

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

nrf-hal-common/src/uarte.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,24 @@ pub enum Error {
492492
BufferNotInRAM,
493493
}
494494

495+
impl fmt::Display for Error {
496+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
497+
use Error::*;
498+
match self {
499+
TxBufferTooSmall => writeln!(f, "tx buffer too small"),
500+
RxBufferTooSmall => writeln!(f, "rx buffer too small"),
501+
TxBufferTooLong => writeln!(f, "tx buffer too long"),
502+
RxBufferTooLong => writeln!(f, "rx buffer too long"),
503+
Transmit => writeln!(f, "transmit error"),
504+
Receive => writeln!(f, "receive error"),
505+
Timeout(t) => writeln!(f, "timeout ({})", t),
506+
BufferNotInRAM => writeln!(f, "buffer not in ram"),
507+
}
508+
}
509+
}
510+
511+
impl core::error::Error for Error {}
512+
495513
impl embedded_io::Error for Error {
496514
fn kind(&self) -> ErrorKind {
497515
match self {

0 commit comments

Comments
 (0)