Struct shortcut_autotyper::Sequences
source · pub struct Sequences(/* private fields */);
Expand description
Structure for collection of defined sequences.
Implementations§
source§impl Sequences
impl Sequences
sourcepub fn new(sequences: &[(&str, &str)]) -> ATResult<Sequences>
pub fn new(sequences: &[(&str, &str)]) -> ATResult<Sequences>
Create new instance of Sequences
if identification name is valid
Command::valid_name()
and unique.
Sequences
are list of tuples, where first value is name
and second required sequence
let seq = Sequences::new(&[("A", "seq a"), ("B", "seq b")]);
assert!(seq.is_ok());
let seq = Sequences::new(&[("~", "invalid seq")]);
assert_eq!(seq, Err(ErrType::InvalidKeyFormat(String::from("~")).into()));
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 sequence key
does not exists.
let seq = Sequences::new(&[("A", "seq a,")]).unwrap();
assert_eq!(seq.get_sequence("A3", &Vec::new()).unwrap(), String::from("seq a,seq a,seq a,"));
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>
Generate sequence from given Command
. Returns string with generated
sequence or error if sequence does not constraint value with command name.
sourcepub fn get(&self, key: &str) -> Option<&String>
pub fn get(&self, key: &str) -> Option<&String>
Returns a reference to the value corresponding to the key.
If value does not exists. Then returns None
.
sourcepub fn get_errors(&self) -> ATVecResult<()>
pub fn get_errors(&self) -> ATVecResult<()>
Find all keys invalid and returns errors caused by them
as ATVecResult
. If there are no invalid keys returns Ok(())
.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Sequences
impl<'de> Deserialize<'de> for Sequences
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for Sequences
impl PartialEq for Sequences
impl StructuralPartialEq for Sequences
Auto Trait Implementations§
impl RefUnwindSafe for Sequences
impl Send for Sequences
impl Sync for Sequences
impl Unpin for Sequences
impl UnwindSafe for Sequences
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