pinakes-core: update remaining modules and tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9e0ff5ea33a5cf697473423e88f167ce6a6a6964
This commit is contained in:
parent
c8425a4c34
commit
3d9f8933d2
44 changed files with 1207 additions and 578 deletions
|
|
@ -14,9 +14,9 @@ pub enum SearchQuery {
|
|||
field: String,
|
||||
value: String,
|
||||
},
|
||||
And(Vec<SearchQuery>),
|
||||
Or(Vec<SearchQuery>),
|
||||
Not(Box<SearchQuery>),
|
||||
And(Vec<Self>),
|
||||
Or(Vec<Self>),
|
||||
Not(Box<Self>),
|
||||
Prefix(String),
|
||||
Fuzzy(String),
|
||||
TypeFilter(String),
|
||||
|
|
@ -149,18 +149,13 @@ fn parse_date_value(s: &str) -> Option<DateValue> {
|
|||
/// Returns `None` if the input is invalid or if the value would overflow.
|
||||
fn parse_size_value(s: &str) -> Option<i64> {
|
||||
let s = s.to_uppercase();
|
||||
let (num_str, multiplier): (&str, i64) = if let Some(n) = s.strip_suffix("GB")
|
||||
{
|
||||
(n, 1024 * 1024 * 1024)
|
||||
} else if let Some(n) = s.strip_suffix("MB") {
|
||||
(n, 1024 * 1024)
|
||||
} else if let Some(n) = s.strip_suffix("KB") {
|
||||
(n, 1024)
|
||||
} else if let Some(n) = s.strip_suffix('B') {
|
||||
(n, 1)
|
||||
} else {
|
||||
(s.as_str(), 1)
|
||||
};
|
||||
let (num_str, multiplier): (&str, i64) = s
|
||||
.strip_suffix("GB")
|
||||
.map(|n| (n, 1024 * 1024 * 1024_i64))
|
||||
.or_else(|| s.strip_suffix("MB").map(|n| (n, 1024 * 1024)))
|
||||
.or_else(|| s.strip_suffix("KB").map(|n| (n, 1024)))
|
||||
.or_else(|| s.strip_suffix('B').map(|n| (n, 1)))
|
||||
.unwrap_or((s.as_str(), 1));
|
||||
|
||||
let num: i64 = num_str.parse().ok()?;
|
||||
num.checked_mul(multiplier)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue