From 3a523c3c8ac1bf9094dbe65a6f53b71085438c0c Mon Sep 17 00:00:00 2001 From: main Date: Fri, 20 Mar 2026 23:31:29 -0400 Subject: Open the metric unit vocabulary --- crates/fidget-spinner-store-sqlite/src/lib.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'crates/fidget-spinner-store-sqlite/src') diff --git a/crates/fidget-spinner-store-sqlite/src/lib.rs b/crates/fidget-spinner-store-sqlite/src/lib.rs index fbdbb32..253929e 100644 --- a/crates/fidget-spinner-store-sqlite/src/lib.rs +++ b/crates/fidget-spinner-store-sqlite/src/lib.rs @@ -3033,19 +3033,12 @@ fn parse_frontier_status(raw: &str) -> Result { } fn parse_metric_unit(raw: &str) -> Result { - match raw { - "seconds" => Ok(MetricUnit::Seconds), - "bytes" => Ok(MetricUnit::Bytes), - "count" => Ok(MetricUnit::Count), - "ratio" => Ok(MetricUnit::Ratio), - "custom" => Ok(MetricUnit::Custom), - _ => Err(to_sql_conversion_error(StoreError::Json( - serde_json::Error::io(io::Error::new( - io::ErrorKind::InvalidData, - format!("invalid metric unit `{raw}`"), - )), - ))), - } + MetricUnit::new(raw).map_err(|error| { + to_sql_conversion_error(StoreError::Json(serde_json::Error::io(io::Error::new( + io::ErrorKind::InvalidData, + error.to_string(), + )))) + }) } fn parse_optimization_objective(raw: &str) -> Result { -- cgit v1.2.3