Struct shortcut_autotyper::Combinations
source · pub struct Combinations { /* private fields */ }
Expand description
Combinations of existing Sequences
.
Implementations§
source§impl Combinations
impl Combinations
sourcepub fn new(
sequences: Sequences,
combinations: &[(&str, &str)]
) -> ATResult<Combinations>
pub fn new( sequences: Sequences, combinations: &[(&str, &str)] ) -> ATResult<Combinations>
Create new instance of Combinations
if identification name is valid
and unique in combinations and sequences
. Otherwise returns error.
let seq = Sequences::new(&[("A", "seq a"), ("B", "b")]).unwrap();
let comb = Combinations::new(seq, &[("X", "A2 B3")]);
assert!(comb.is_ok());
sourcepub fn get_sequence_cmd(
&self,
command: &Command,
args: &Vec<String>
) -> ATResult<String>
pub fn get_sequence_cmd( &self, command: &Command, args: &Vec<String> ) -> ATResult<String>
Works similarly as Combinations::get_sequence()
, only takes reference
to Command
instead of key
.
sourcepub fn get_sequence(&self, key: &str, args: &Vec<String>) -> ATResult<String>
pub fn get_sequence(&self, key: &str, args: &Vec<String>) -> ATResult<String>
Generate sequence from given key
. Returns string with generated
sequence or error if key
is invalid or key
does not exists in sequences
or combinations.
let seq = Sequences::new(&[("A", "seq a"), ("B", "b")]).unwrap();
let comb = Combinations::new(seq, &[("X", "A B3")]).unwrap();
assert_eq!(comb.get_sequence("X", &Vec::new()).unwrap(), String::from("seq abbb"));
sourcepub fn get_errors(&self) -> ATVecResult<()>
pub fn get_errors(&self) -> ATVecResult<()>
Returns list of all errors in Combinations
. If there is no error,
returns Ok(())
.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if Combinations
are valid.
sourcepub fn insert(&mut self, key: &str, value: &str) -> ATResult<()>
pub fn insert(&mut self, key: &str, value: &str) -> ATResult<()>
Insert new combination to existing combinations if key
is valid
and in value
are only existing Sequences
or Combinations
.
let seq = Sequences::new(&[("A", "seq a"), ("B", "b")]).unwrap();
let mut comb = Combinations::new(seq, &[]).unwrap();
assert_eq!(comb.insert("X", "A B3"), Ok(()));
assert_eq!(
comb.insert("X", "A B3"),
Err(ErrType::KeyIsInCombinations(String::from("X")).into())
);
assert_eq!(
comb.insert("A", "A B3"),
Err(ErrType::KeyIsInSequences(String::from("A")).into())
);
assert_eq!(
comb.insert("C", "A D3"),
Err(ErrType::SequenceNotExist(String::from("D")).into())
);
sourcepub fn list_all_commands(&self) -> Vec<&String>
pub fn list_all_commands(&self) -> Vec<&String>
Retrieves a sorted list of references to all available commands in the current context.
This function returns a vector containing references
to all commands found in the sequences
and combinations
data structures of the current context. The commands
are sorted alphabetically in ascending order.
§Return Value
A Vec<&String>
containing references to all available commands,
sorted in ascending order.
Trait Implementations§
source§impl Debug for Combinations
impl Debug for Combinations
source§impl<'de> Deserialize<'de> for Combinations
impl<'de> Deserialize<'de> for Combinations
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Combinations
impl PartialEq for Combinations
source§fn eq(&self, other: &Combinations) -> bool
fn eq(&self, other: &Combinations) -> bool
self
and other
values to be equal, and is used
by ==
.