Implemented multiple U2f keys, key names, and compromised checks

This commit is contained in:
Daniel García
2019-02-14 02:03:37 +01:00
parent 6027b969f5
commit a744b9437a
3 changed files with 135 additions and 83 deletions

View File

@@ -47,10 +47,13 @@ impl NumberOrString {
}
}
fn into_i32(self) -> Option<i32> {
fn into_i32(self) -> ApiResult<i32> {
use std::num::ParseIntError as PIE;
match self {
NumberOrString::Number(n) => Some(n),
NumberOrString::String(s) => s.parse().ok(),
NumberOrString::Number(n) => Ok(n),
NumberOrString::String(s) => s
.parse()
.map_err(|e: PIE| crate::Error::new("Can't convert to number", e.to_string())),
}
}
}