pub struct EscapeWatcher { /* private fields */ }Expand description
Observes inbound CDC bytes for the rescue prefix
Ctrl-C Ctrl-C Ctrl-C dfu followed by \r or \n. On match,
returns RescueAction::TriggerDfu so the caller can put the
device into serial DFU mode independent of the CLI session.
The watcher is non-consuming: callers should hand each received
byte to EscapeWatcher::observe before passing it to the CLI
parser, not instead of. This preserves Ctrl-C’s “abort” semantics
inside the CLI.
Implementations§
Source§impl EscapeWatcher
impl EscapeWatcher
pub const fn new() -> Self
Sourcepub fn observe(&mut self, byte: u8) -> RescueAction
pub fn observe(&mut self, byte: u8) -> RescueAction
Feed one received byte. Returns TriggerDfu exactly once
on completion of the magic sequence; further bytes return None
until reset is called.
Sourcepub fn observe_slice(&mut self, bytes: &[u8]) -> RescueAction
pub fn observe_slice(&mut self, bytes: &[u8]) -> RescueAction
Convenience: observe every byte in a slice.