pub struct Encoder<const MSG_MAX: usize> { /* private fields */ }
Implementations§
Source§impl<const MSG_MAX: usize> Encoder<MSG_MAX>
impl<const MSG_MAX: usize> Encoder<MSG_MAX>
pub fn new() -> Self
Sourcepub fn with_message(self, message_str: &str, edit_pos_end: bool) -> Self
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.
Sourcepub fn with_edit_position(self, pos: usize) -> Self
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.
Sourcepub fn with_character_set(self, character_set: CharacterSet) -> Self
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.
Sourcepub fn with_morse_code_set(self, morse_code_set: MorseCodeSet) -> Self
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.
Sourcepub fn with_message_pos_clamping(self) -> Self
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);
Sourcepub fn build(self) -> MorseEncoder<MSG_MAX>
pub fn build(self) -> MorseEncoder<MSG_MAX>
Build and get yourself a shiny new MorseEncoder.
The ring is yours now…