morse_codec::decoder

Struct MorseDecoder

Source
pub struct MorseDecoder<const MSG_MAX: usize> {
    pub message: Message<MSG_MAX>,
    /* private fields */
}
Expand description

This is the concrete implementation of the decoder.

It doesn’t have a new function, or public data members, so to get an instance of it, use public builder interface Decoder.

Fields§

§message: Message<MSG_MAX>

Implementations§

Source§

impl<const MSG_MAX: usize> MorseDecoder<MSG_MAX>

Source

pub fn get_reference_short(&self) -> u16

Returns currently resolved reference short signal duration.

Reference short signal is resolved continuously by the decoder as signal events pour in. As longer signal durations are calculated by multiplying this value, it might be useful for the client code.

Source

pub fn get_wpm(&self) -> u16

Returns the current signal entry speed in Words Per Minute format.

Source

pub fn get_last_decoded_char(&self) -> Character

Returns last decoded character for easy access.

Source

pub fn add_signal_to_character(&mut self, signal: Option<MorseSignal>)

Directly add a prepared signal to the character.

Signal duration resolving is done by the client code, or you’re using a prepared signal.

Source

pub fn add_current_char_to_message(&mut self)

Add current decoded character to the message.

This happens automatically when using signal_event calls. Use this with add_signal_to_character directly with prepared MorseSignal enums.

Source

pub fn signal_event_end(&mut self, end_word: bool)

Manually end a sequence of signals.

This decodes the current character and moves to the next one. With end_word flag it will optionally add a space after it. Especially useful when client code can’t determine if signal input by the operator ended, because no other high signal is following the low signal at the end. At that point a separate button or whatever can be used to trigger this function.

Source

pub fn signal_event(&mut self, duration_ms: u16, is_high: bool)

Send signal events to the decoder, filling signal buffer one event at a time.

When a character ending long space signal or a word ending long space is sent, signal buffer will be decoded automatically and character will be added to message. Note that if signal input itself has ended, oftentimes there’s no way to send that signal. Use signal_event_end at that point to manually end the character.

Auto Trait Implementations§

§

impl<const MSG_MAX: usize> Freeze for MorseDecoder<MSG_MAX>

§

impl<const MSG_MAX: usize> RefUnwindSafe for MorseDecoder<MSG_MAX>

§

impl<const MSG_MAX: usize> Send for MorseDecoder<MSG_MAX>

§

impl<const MSG_MAX: usize> Sync for MorseDecoder<MSG_MAX>

§

impl<const MSG_MAX: usize> Unpin for MorseDecoder<MSG_MAX>

§

impl<const MSG_MAX: usize> UnwindSafe for MorseDecoder<MSG_MAX>

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.