Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

Streaming CW decoder. See the module docs for usage.

Implementations§

Source§

impl Decoder

Source

pub const fn new() -> Self

Construct an empty decoder. const so it can be placed in a static without lazy initialisation.

Source

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.

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Number of characters currently in the recent-history ring.

Source

pub fn is_empty(&self) -> bool

True iff no characters have been decoded yet (or Decoder::clear was called).

Source

pub fn clear(&mut self)

Drop the recent history and reset in-flight Morse state. The next pulse / gap is treated as the start of a fresh stream.

Trait Implementations§

Source§

impl Default for Decoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.