Struct tockloader_proto::ResponseDecoder
[−]
[src]
pub struct ResponseDecoder { /* fields omitted */ }
The ResponseDecoder
takes bytes and gives you Responses
s.
Methods
impl ResponseDecoder
[src]
fn new() -> ResponseDecoder
[src]
Create a new ResponseDecoder
.
The decoder is fed bytes with the receive
method.
fn read<F>(&mut self, buffer: &[u8], callback: F) -> Result<(), Error> where
F: Fn(&Response),
[src]
F: Fn(&Response),
Decode a whole buffers worth of bytes.
Due to lifetime problems, the decoded Response
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<Response>, 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 Some(Response)
containing the
decoded Response.
fn set_payload_len(&mut self, length: usize) -> Result<(), Error>
[src]
Set the expected length of an unbounded message. This depends entirely on the last command you sent.