pub struct Receiver { /* private fields */ }Expand description
Turns a stick’s byte stream into Messages, without allocating.
Push bytes with Receiver::extend in whatever chunks the port delivers, then call
Receiver::next_message until it returns None. Noise and corrupted stick frames
come out as errors and are skipped; the next valid frame always decodes.
Implementations§
Source§impl Receiver
impl Receiver
Sourcepub fn extend(&mut self, bytes: &[u8]) -> usize
pub fn extend(&mut self, bytes: &[u8]) -> usize
Add bytes from the port. Returns how many were taken: fewer than given only when
the buffer is full of an unfinished frame; call Receiver::next_message and
extend with the rest.
Sourcepub fn next_message(&mut self) -> Option<Result<Message<'_>>>
pub fn next_message(&mut self) -> Option<Result<Message<'_>>>
The next message, an error for bytes that were skipped, or None until more
bytes arrive.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Receiver
impl Freeze for Receiver
impl Move for Receiver
impl RefUnwindSafe for Receiver
impl Send for Receiver
impl Sync for Receiver
impl Unpin for Receiver
impl UnsafeUnpin for Receiver
impl UnwindSafe for Receiver
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