option_parser: Create generic type Tuple

Creates a new generic type Tuple so that the same implementation of
FromStr trait can be reused for both parsing a list of two integers and
parsing a list of one integer associated with a list of integers.

This anticipates the need for retrieving sublists, which will be needed
when trying to describe the host CPU affinity for every vCPU.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2021-11-08 16:52:53 +01:00
parent e4cbafcd01
commit ad521fd4e4
2 changed files with 35 additions and 15 deletions

View File

@@ -6,7 +6,7 @@
use clap::ArgMatches;
use net_util::MacAddr;
use option_parser::{
ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, TupleTwoIntegers,
ByteSized, IntegerList, OptionParser, OptionParserError, StringList, Toggle, Tuple,
};
use std::collections::HashMap;
use std::convert::From;
@@ -1942,7 +1942,7 @@ impl NumaConfig {
.map_err(Error::ParseNuma)?
.map(|v| v.0.iter().map(|e| *e as u8).collect());
let distances = parser
.convert::<TupleTwoIntegers>("distances")
.convert::<Tuple<u64>>("distances")
.map_err(Error::ParseNuma)?
.map(|v| {
v.0.iter()