pub struct Morse { /* private fields */ }
Expand description
§International standart Morse Code (default feature).
Implementations§
Source§impl Morse
impl Morse
Sourcepub fn from_text(text: &str) -> MorseResult<Morse>
pub fn from_text(text: &str) -> MorseResult<Morse>
Creates International Morse Code struct from text.
§Examples
use morse_lib::Morse;
let morse = Morse::from_text("sos").unwrap();
assert_eq!(morse.to_string(), ". . . ⚊ ⚊ ⚊ . . .");
Sourcepub fn from_bin(bin: &str) -> MorseResult<Morse>
pub fn from_bin(bin: &str) -> MorseResult<Morse>
Creates International Morse Code struct from binary.
§Examples
use morse_lib::Morse;
let morse = Morse::from_bin("101010001110111011100010101").unwrap();
assert_eq!(morse.to_string(), ". . . ⚊ ⚊ ⚊ . . .");
Sourcepub fn dot_as(&mut self, alias: &str)
pub fn dot_as(&mut self, alias: &str)
Creates alias for dot in output string.
§Examples
use morse_lib::Morse;
let mut morse = Morse::from_text("sos").unwrap();
morse.dot_as("🔥");
assert_eq!(morse.to_string(), "🔥 🔥 🔥 ⚊ ⚊ ⚊ 🔥 🔥 🔥");
Sourcepub fn line_as(&mut self, alias: &str)
pub fn line_as(&mut self, alias: &str)
Creates alias for line in output string.
§Examples
use morse_lib::Morse;
let mut morse = Morse::from_text("sos").unwrap();
morse.line_as("➖");
assert_eq!(morse.to_string(), ". . . ➖ ➖ ➖ . . .");
Sourcepub fn whitespace_as(&mut self, alias: &str)
pub fn whitespace_as(&mut self, alias: &str)
Creates alias for whitespace in output string.
§Examples
use morse_lib::Morse;
let mut morse = Morse::from_text("s o").unwrap();
morse.whitespace_as("🚧");
assert_eq!(morse.to_string(), ". . . 🚧 ⚊ ⚊ ⚊");
Sourcepub fn to_beep(&self)
pub fn to_beep(&self)
Play sound that represent Morse Code.
Only available if “audio” feature is enabled.
Sourcepub fn frequency(&mut self, frequency: f32)
pub fn frequency(&mut self, frequency: f32)
Set sound frequency in MHz.
Only available if “audio” feature is enabled.
§Examples
use morse_lib::Morse;
let mut morse = Morse::from_text("s o").unwrap();
morse.frequency(643.0);
Sourcepub fn play_speed(&mut self, speed: f32)
pub fn play_speed(&mut self, speed: f32)
Set sound speed.
Only available if “audio” feature is enabled.
- ‘1’ - normal speed
- ‘> 1’ - faster
- ‘< 1’ - slower
§Examples
use morse_lib::Morse;
let mut morse = Morse::from_text("s o").unwrap();
morse.play_speed(2.0);
Sourcepub fn to_bin_str(&self) -> String
pub fn to_bin_str(&self) -> String
Creates binary-formatted Morse Code.
§Examples
use morse_lib::Morse;
let morse = Morse::from_text("sos").unwrap();
assert_eq!(morse.to_bin_str(), "101010001110111011100010101");
Trait Implementations§
Source§impl IntoIterator for Morse
impl IntoIterator for Morse
Source§impl TMorse for Morse
impl TMorse for Morse
Source§fn parse_text(&mut self, text: &str) -> MorseResult<()>
fn parse_text(&mut self, text: &str) -> MorseResult<()>
Parse text into Morse Code.
impl StructuralPartialEq for Morse
Auto Trait Implementations§
impl Freeze for Morse
impl RefUnwindSafe for Morse
impl Send for Morse
impl Sync for Morse
impl Unpin for Morse
impl UnwindSafe for Morse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more