pub struct CommandDecoder { /* private fields */ }
Expand description
The ComandDecoder
takes bytes and gives you Command
s.
Implementations§
Source§impl CommandDecoder
impl CommandDecoder
Sourcepub fn new() -> CommandDecoder
pub fn new() -> CommandDecoder
Create a new CommandDecoder
.
The decoder is fed bytes with the receive
method.
Sourcepub fn read<F>(&mut self, buffer: &[u8], callback: F) -> Result<(), Error>
pub fn read<F>(&mut self, buffer: &[u8], callback: F) -> Result<(), Error>
Decode a whole buffers worth of bytes.
Due to lifetime problems, the decoded Command
s are sent via callback
rather
than being returned.
Sourcepub fn receive(&mut self, ch: u8) -> Result<Option<Command<'_>>, Error>
pub fn receive(&mut self, ch: u8) -> Result<Option<Command<'_>>, Error>
Process incoming bytes.
The decoder is fed bytes with the receive
method. If not enough
bytes have been seen, this function returns None
. Once enough bytes
have been seen, it returns Ok(Some(Command))
containing the decoded
Command. It returns Err
if it doesn’t like the byte received.
Auto Trait Implementations§
impl Freeze for CommandDecoder
impl RefUnwindSafe for CommandDecoder
impl Send for CommandDecoder
impl Sync for CommandDecoder
impl Unpin for CommandDecoder
impl UnwindSafe for CommandDecoder
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