morse_codec::encoder

Struct MorseEncoder

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

Fields§

§message: Message<MSG_MAX>

Implementations§

Source§

impl<const MSG_MAX: usize> MorseEncoder<MSG_MAX>

Source

pub fn encode_character(&mut self, ch: &Character) -> Result<(), &str>

Encode a single character at the edit position and add it both to the message and encoded_message.

Source

pub fn encode_slice(&mut self, str_slice: &str) -> Result<(), &str>

Encode a &str slice at the edit position and add it both to the message and encoded message.

Note if the slice exceeds maximum message length it will return an error. Non-ASCII characters will be ignored.

Source

pub fn encode_message_all(&mut self)

Encode the entire message from start to finish and save it to encoded_message.

Source

pub fn get_last_char_as_morse_charray(&self) -> Option<MorseCharray>

Get last encoded message character as Option<Character> arrays of morse code.

Arrays will have a fixed length of MORSE_ARRAY_LENGTH and if there’s no signal the option will be None.

Source

pub fn get_last_char_as_sdm(&self) -> Option<SDMArray>

Get last encoded message character as Option<SDM> arrays of morse code.

The multiplier values then can be used to calculate durations of individual signals to play or animate the morse code. It’ll be great to filter-out Empty values of SDM arrays.

Source

pub fn get_encoded_message_as_morse_charrays( &self, ) -> impl Iterator<Item = Option<MorseCharray>> + '_

Get an iterator to encoded message as Option<Character> arrays of morse code. Arrays will have a fixed length of MORSE_ARRAY_LENGTH and if there’s no signal the option will be None. So it will be good to filter them out.

Source

pub fn get_encoded_message_as_sdm_arrays( &self, ) -> impl Iterator<Item = Option<SDMArray>> + '_

Get an iterator to entire encoded message as Option<SDM> arrays of morse code. The multiplier values then can be used to calculate durations of individual signals to play or animate the morse code. It’ll be good to filter Empty values that might fill the arrays at the end.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<const MSG_MAX: usize> UnwindSafe for MorseEncoder<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.