Struct tockloader_proto::CommandDecoder
[−]
[src]
pub struct CommandDecoder { /* fields omitted */ }
The ComandDecoder
takes bytes and gives you Command
s.
Methods
impl CommandDecoder
[src]
fn new() -> CommandDecoder
[src]
Create a new CommandDecoder
.
The decoder is fed bytes with the receive
method.
fn read<F>(&mut self, buffer: &[u8], callback: F) -> Result<(), Error> where
F: Fn(&Command),
[src]
F: Fn(&Command),
Decode a whole buffers worth of bytes.
Due to lifetime problems, the decoded Command
s are sent via callback
rather
than being returned.
fn reset(&mut self)
[src]
Empty the RX buffer.
fn receive(&mut self, ch: u8) -> Result<Option<Command>, Error>
[src]
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.