pub struct Decoder { /* private fields */ }Expand description
Streaming CW decoder. See the module docs for usage.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct an empty decoder. const so it can be placed in a
static without lazy initialisation.
Sourcepub fn on_transition(&mut self, now_us: u64, key_down: bool, wpm: u8)
pub fn on_transition(&mut self, now_us: u64, key_down: bool, wpm: u8)
Feed a key-line transition.
now_us is the absolute time of the edge — any monotonic clock
works since only deltas are used. key_down is the new state of
the line. wpm is the sender’s speed; thresholds derive from it.
O(1) work — safe to call from a high-priority context.
Sourcepub fn poll(&mut self, now_us: u64, wpm: u8)
pub fn poll(&mut self, now_us: u64, wpm: u8)
Poll the decoder so pending characters and inter-word spaces get flushed during extended silence.
Call at a regular cadence (e.g. once per UI tick). Idempotent during a single sustained silence — repeated calls emit at most one character and one space.
O(1) work.
Sourcepub fn snapshot(&self, out: &mut [u8]) -> usize
pub fn snapshot(&self, out: &mut [u8]) -> usize
Copy the recent decoded history (oldest-first ASCII bytes) into
out. Returns the number of bytes written. Does not mutate.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True iff no characters have been decoded yet (or Decoder::clear
was called).