Struct shortcut_autotyper::Command
source · pub struct Command { /* private fields */ }
Expand description
Basic structure containing name and number of repetition.
Implementations§
source§impl Command
impl Command
sourcepub fn new(name: &str) -> Command
pub fn new(name: &str) -> Command
Create new Command
with only one repetition.
name
is given name and does not have to be valid
sourcepub fn new_number(name: &str, num: usize) -> Command
pub fn new_number(name: &str, num: usize) -> Command
Create new Command
with given number of repetitions.
name
is given name and does not have to be validnum
is the number of repetitions
sourcepub fn new_range(name: &str, range: Range<usize>) -> Command
pub fn new_range(name: &str, range: Range<usize>) -> Command
Create new Command
with number of repetitions randomly
selected from given range.
name
is given name and have not to be validrange
is a half-open range of possible repetitions
let cmd = Command::new_range("A", 3..5);
let times = cmd.get_times();
assert!(times >= 3);
assert!(times < 5);
sourcepub fn valid_name(name: &str) -> ATResult<()>
pub fn valid_name(name: &str) -> ATResult<()>
Check if given name
is valid. A valid name can consist
only of alphabetical characters. If given name is not valid,
then it returns an error with ErrType::InvalidKeyFormat
.
assert_eq!(Command::valid_name("A"), Ok(()));
assert_eq!(
Command::valid_name("A~"),
Err(ErrType::InvalidKeyFormat(String::from("A~")).into())
);
assert_eq!(
Command::valid_name("A B"),
Err(ErrType::InvalidKeyFormat(String::from("A B")).into())
);
sourcepub fn are_valid_names<'a, I: Iterator<Item = &'a String>>(
iter: I
) -> ATVecResult<()>
pub fn are_valid_names<'a, I: Iterator<Item = &'a String>>( iter: I ) -> ATVecResult<()>
Check if given names are valid same as Command::valid_name()
and returns a Vec
of ErrType::InvalidKeyFormat
.
iter
is iterator of given names
Trait Implementations§
source§impl PartialEq for Command
impl PartialEq for Command
impl Eq for Command
impl StructuralPartialEq for Command
Auto Trait Implementations§
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
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