pub struct Sequences(/* private fields */);
Expand description

Structure for collection of defined sequences.

Implementations§

source§

impl Sequences

source

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

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.

source

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.

source

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(()).

source

pub fn is_valid(&self) -> bool

Check if all keys in sequence are valid.

source

pub fn insert(&mut self, key: &str, value: &str) -> ATResult<()>

Insert key and value to sequences. If key is invalid, or is in sequences, error will be returned.

source

pub fn get_keys(&self) -> Keys<'_, String, String>

Retrieves an iterator over the sequences.

§Return Value

An iterator of type Keys<'_, String, String> over the keys of the sequences.

Trait Implementations§

source§

impl Debug for Sequences

source§

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

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

impl Default for Sequences

source§

fn default() -> Sequences

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Sequences

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 Sequences

source§

fn eq(&self, other: &Sequences) -> 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 Sequences

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 Sequences

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>,