rename IterableRx to RxIter

This commit is contained in:
Vladan Popovic 2022-06-21 01:27:27 +02:00
parent 5a190e4890
commit 55e5b0dc96

View file

@ -11,7 +11,7 @@ use esp_idf_hal::serial::{self, Rx, Tx};
pub type Result<T> = std::result::Result<T, ModemError>; pub type Result<T> = std::result::Result<T, ModemError>;
pub struct Modem<UART: serial::Uart> { pub struct Modem<UART: serial::Uart> {
rx: IterableRx<UART>, rx: RxIter<UART>,
tx: Tx<UART>, tx: Tx<UART>,
} }
@ -32,12 +32,12 @@ impl std::fmt::Display for ModemError {
} }
} }
pub struct IterableRx<UART: serial::Uart> { pub struct RxIter<UART: serial::Uart> {
inner: Rx<UART>, inner: Rx<UART>,
timeout: Duration, timeout: Duration,
} }
impl<UART: serial::Uart> IterableRx<UART> { impl<UART: serial::Uart> RxIter<UART> {
fn reset(&mut self, timeout: Duration) -> &mut Self { fn reset(&mut self, timeout: Duration) -> &mut Self {
self.timeout = timeout; self.timeout = timeout;
self self
@ -69,7 +69,7 @@ impl<UART: serial::Uart> IterableRx<UART> {
} }
} }
impl<UART: serial::Uart> Iterator for IterableRx<UART> { impl<UART: serial::Uart> Iterator for RxIter<UART> {
type Item = u8; type Item = u8;
/// `nb` returns Ok(byte), or one of Err(WouldBlock) and Err(Other) which isn't of anyone's /// `nb` returns Ok(byte), or one of Err(WouldBlock) and Err(Other) which isn't of anyone's
@ -98,7 +98,7 @@ impl<UART: serial::Uart> Iterator for IterableRx<UART> {
impl<UART: serial::Uart> Modem<UART> { impl<UART: serial::Uart> Modem<UART> {
pub fn new(tx: Tx<UART>, rx: Rx<UART>) -> Self { pub fn new(tx: Tx<UART>, rx: Rx<UART>) -> Self {
Self { Self {
rx: IterableRx { inner: rx, timeout: Duration::from_millis(0) }, rx: RxIter { inner: rx, timeout: Duration::from_millis(0) },
tx, tx,
} }
} }