pub struct SerialReader<R> { /* private fields */ }Expand description
Buffered UART protocol frame reader wrapping a SerialRead implementation.
Serves as the RX counterpart to writer_task. It is structured as a
borrowed reader rather than a standalone background task so that unconsumed
trailing bytes in the FrameParser can be recovered via
Self::take_unconsumed when a session renegotiates.
Implementations§
Source§impl<R: SerialRead> SerialReader<R>
impl<R: SerialRead> SerialReader<R>
Sourcepub fn new(client: R) -> Self
pub fn new(client: R) -> Self
Creates a new SerialReader with an empty parser buffer.
Sourcepub fn with_initial_data(client: R, initial_data: &[u8]) -> Self
pub fn with_initial_data(client: R, initial_data: &[u8]) -> Self
Creates a new SerialReader pre-populated with initial_data.
Sourcepub fn take_unconsumed(&mut self) -> Vec<u8> ⓘ
pub fn take_unconsumed(&mut self) -> Vec<u8> ⓘ
Drains and returns all unconsumed raw bytes currently buffered in the parser.
Sourcepub fn requeue_frame(&mut self, frame: &Frame)
pub fn requeue_frame(&mut self, frame: &Frame)
Re-encodes frame and prepends it ahead of any unconsumed bytes in the parser buffer.
Sourcepub async fn next_frame(&mut self) -> Result<Frame>
pub async fn next_frame(&mut self) -> Result<Frame>
Reads from the underlying serial device until a complete, valid uart_fpl::Frame is parsed.
§Errors
Returns TargetDriverError::Eof if the underlying reader returns an empty read,
or propagates any error from SerialRead::serial_read.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for SerialReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for SerialReader<R>where
R: RefUnwindSafe,
impl<R> Send for SerialReader<R>where
R: Send,
impl<R> Sync for SerialReader<R>where
R: Sync,
impl<R> Unpin for SerialReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for SerialReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for SerialReader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more