pub struct StreamingParser { /* private fields */ }
Expand description
A streaming parser that accumulates bytes until a complete SBUS frame is decoded
This parser is designed for real-world scenarios where data arrives incrementally from serial ports. It handles:
- Partial frame data
- Synchronization recovery
- Mid-stream starts
§Example
let mut parser = StreamingParser::new();
// Feed bytes as they arrive
if let Some(packet) = parser.push_byte(0x0F).unwrap() {
// Won't return a packet yet
}
// Or feed chunks
let data = [0x0F, 0x00, 0x00, /* ... */];
for packet in parser.push_bytes(&data) {
println!("Got packet: {:?}", packet.unwrap());
}
Implementations§
Source§impl StreamingParser
impl StreamingParser
Sourcepub const fn stats(&self) -> &StreamingStats
pub const fn stats(&self) -> &StreamingStats
Get parser statistics
Sourcepub fn push_byte(&mut self, byte: u8) -> Result<Option<SbusPacket>, SbusError>
pub fn push_byte(&mut self, byte: u8) -> Result<Option<SbusPacket>, SbusError>
Push a single byte into the parser
Returns Some(packet)
if a complete frame was decoded, None
otherwise
Sourcepub fn push_bytes<'a>(&'a mut self, data: &'a [u8]) -> StreamingIterator<'a> ⓘ
pub fn push_bytes<'a>(&'a mut self, data: &'a [u8]) -> StreamingIterator<'a> ⓘ
Push multiple bytes into the parser
Returns an iterator over successfully decoded packets
Trait Implementations§
Source§impl Clone for StreamingParser
impl Clone for StreamingParser
Source§fn clone(&self) -> StreamingParser
fn clone(&self) -> StreamingParser
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for StreamingParser
impl Debug for StreamingParser
Source§impl Default for StreamingParser
impl Default for StreamingParser
Auto Trait Implementations§
impl Freeze for StreamingParser
impl RefUnwindSafe for StreamingParser
impl Send for StreamingParser
impl Sync for StreamingParser
impl Unpin for StreamingParser
impl UnwindSafe for StreamingParser
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
Mutably borrows from an owned value. Read more