pub struct CommandKeyParser { /* private fields */ }Expand description
State machine that splits stdin bytes into “data to send” vs. “commands to dispatch” using the configurable escape key.
Implementations§
Source§impl CommandKeyParser
impl CommandKeyParser
Sourcepub const fn new(escape: u8) -> Self
pub const fn new(escape: u8) -> Self
Builds a parser whose command key is escape (commonly ^T =
0x14).
Sourcepub const fn escape_byte(&self) -> u8
pub const fn escape_byte(&self) -> u8
Returns the escape byte this parser was configured with.
Sourcepub fn feed(&mut self, byte: u8) -> ParseOutput
pub fn feed(&mut self, byte: u8) -> ParseOutput
Feed a single input byte; returns whatever the parser decided to emit for it.
State transitions (with ^T as the escape byte for illustration):
| from \ byte | ^T | Esc (0x1b) | mapped command | b | digit (in baud sub-state) | \r / \n (in baud sub-state) | other |
|---|---|---|---|---|---|---|---|
| Default | → AwaitingCommand | → Data(byte) | → Data(byte) | → Data(byte) | n/a | n/a | → Data(byte) |
| AwaitingCommand | → Data(^T) | → Default | → Command(…) | → AwaitingBaudDigits | n/a | n/a | → Default (drop) |
| AwaitingBaudDigits | → Default (drop) | → Default | → Default (drop) | → Default (drop) | append, stay | → SetBaud / Default | → Default (drop) |
Trait Implementations§
Source§impl Default for CommandKeyParser
impl Default for CommandKeyParser
Source§fn default() -> Self
fn default() -> Self
Creates a parser whose escape byte is DEFAULT_ESCAPE_BYTE
(^A / 0x01).
Auto Trait Implementations§
impl Freeze for CommandKeyParser
impl RefUnwindSafe for CommandKeyParser
impl Send for CommandKeyParser
impl Sync for CommandKeyParser
impl Unpin for CommandKeyParser
impl UnsafeUnpin for CommandKeyParser
impl UnwindSafe for CommandKeyParser
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