morse_codec::encoder

Struct Encoder

Source
pub struct Encoder<const MSG_MAX: usize> { /* private fields */ }

Implementations§

Source§

impl<const MSG_MAX: usize> Encoder<MSG_MAX>

Source

pub fn new() -> Self

Source

pub fn with_message(self, message_str: &str, edit_pos_end: bool) -> Self

Build encoder with a starting message.

edit_pos_end means we’ll continue encoding from the end of this string. If you pass false to it, we’ll start from the beginning.

Source

pub fn with_edit_position(self, pos: usize) -> Self

Build encoder with an arbitrary editing start position.

Maybe client code saved the previous editing position to an EEPROM, harddisk, local storage in web and wants to continue from that.

Source

pub fn with_character_set(self, character_set: CharacterSet) -> Self

Use a different character set than default english alphabet.

This can be helpful to create a message with trivial encryption. Letters can be shuffled for example. With utf-8 feature flag, a somewhat stronger encryption can be used. These kind of encryptions can easily be broken with powerful algorithms and AI. DON’T use it for secure communication.

Source

pub fn with_morse_code_set(self, morse_code_set: MorseCodeSet) -> Self

Use a different morse code set than the default.

It’s mainly useful for a custom morse code set with utf8 character sets. Different alphabets have different corresponding morse code sets.

Source

pub fn with_message_pos_clamping(self) -> Self

Change the wrapping behaviour of message position to clamping.

This will prevent the position cycling back to 0 when overflows or jumping forward to max when falls below 0. Effectively limiting the position to move within the message length from 0 to message length maximum without jumps.

If at one point you want to change it back to wrapping again:

encoder.message.set_edit_position_clamp(false);
Source

pub fn build(self) -> MorseEncoder<MSG_MAX>

Build and get yourself a shiny new MorseEncoder.

The ring is yours now…

Trait Implementations§

Source§

impl<const MSG_MAX: usize> Default for Encoder<MSG_MAX>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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