Enum cobs::DecoderState
source · pub enum DecoderState {
Idle,
Grab(u8),
GrabChain(u8),
}
Expand description
The DecoderState
is used to track the current state of a
streaming decoder. This struct does not contain the output buffer
(or a reference to one), and can be used when streaming the decoded
output to a custom data type.
Variants§
Idle
State machine has not received any non-zero bytes
Grab(u8)
1-254 bytes, can be header or 00
GrabChain(u8)
255 bytes, will be a header next
Implementations§
source§impl DecoderState
impl DecoderState
sourcepub fn feed(&mut self, data: u8) -> Result<DecodeResult, ()>
pub fn feed(&mut self, data: u8) -> Result<DecodeResult, ()>
Push a single encoded byte into the state machine. If the input was unexpected, such as an early end of a framed message segment, an Error will be returned, and the current associated output buffer contents should be discarded.
If a complete message is indicated, the decoding state machine will automatically reset itself to the Idle state, and may be used to begin decoding another message.
NOTE: Sentinel value must be included in the input to this function for the decoding to complete