pub struct Combinations { /* private fields */ }
Expand description

Combinations of existing Sequences.

Implementations§

source§

impl Combinations

source

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());
source

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.

source

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"));
source

pub fn get_errors(&self) -> ATVecResult<()>

Returns list of all errors in Combinations. If there is no error, returns Ok(()).

source

pub fn is_valid(&self) -> bool

Check if Combinations are valid.

source

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())
   );
source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Combinations

source§

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 Combinations

source§

fn eq(&self, other: &Combinations) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Combinations

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Combinations

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,