From 836d2a16c3d785a0a5db5cbd97fb50bfd8c7b4ee Mon Sep 17 00:00:00 2001 From: Juraj Sadel Date: Tue, 7 Jan 2025 15:42:06 +0100 Subject: [PATCH] Remove ZeroLengthBufferPassed variant --- esp-hal/src/uart.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index d6e0aa6a4a9..79a90a0c761 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -257,11 +257,6 @@ const CMD_CHAR_DEFAULT: u8 = 0x2b; #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum Error { - /// A zero lenght buffer was passed. - /// - /// This error occurs when an empty buffer is passed. - ZeroLengthBufferPassed, - /// The RX FIFO overflow happened. /// /// This error occurs when RX FIFO is full and a new byte is received. @@ -292,7 +287,6 @@ impl core::error::Error for Error {} impl core::fmt::Display for Error { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { - Error::ZeroLengthBufferPassed => write!(f, "A zero lenght buffer was passed"), Error::FifoOverflowed => write!(f, "The RX FIFO overflowed"), Error::GlitchOccurred => write!(f, "A glitch was detected on the RX line"), Error::FrameFormatViolated => write!(f, "A framing error was detected on the RX line"), @@ -1801,10 +1795,10 @@ where /// /// # Ok /// When successful, returns the number of bytes written to buf. - /// This method will never return Ok(0) + /// If buffer is empty, Ok(0) is returned. pub async fn read_async(&mut self, buf: &mut [u8]) -> Result { if buf.is_empty() { - return Err(Error::ZeroLengthBufferPassed); + return Ok(0); } loop {