feat: support all alias (#3660)

This commit is contained in:
Matthias Seitz
2023-07-07 21:04:19 +02:00
committed by GitHub
parent 93865ef916
commit 74b21c108c

View File

@@ -563,9 +563,12 @@ impl FromStr for RpcModuleSelection {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let modules = s.split(',');
RpcModuleSelection::try_from_selection(modules)
let mut modules = s.split(',').peekable();
let first = modules.peek().copied().ok_or(ParseError::VariantNotFound)?;
match first {
"all" | "All" => Ok(RpcModuleSelection::All),
_ => RpcModuleSelection::try_from_selection(modules),
}
}
}
@@ -1667,6 +1670,12 @@ impl fmt::Debug for RpcServerHandle {
mod tests {
use super::*;
#[test]
fn parse_rpc_module_selection() {
let selection = "all".parse::<RpcModuleSelection>().unwrap();
assert_eq!(selection, RpcModuleSelection::All);
}
#[test]
fn identical_selection() {
assert!(RpcModuleSelection::are_identical(