diff options
| author | main <main@swarm.moe> | 2026-03-20 23:31:29 -0400 |
|---|---|---|
| committer | main <main@swarm.moe> | 2026-03-20 23:31:29 -0400 |
| commit | 3a523c3c8ac1bf9094dbe65a6f53b71085438c0c (patch) | |
| tree | 5055c0e64f3024059221d341f3b81434cae34586 /crates/fidget-spinner-store-sqlite/src/lib.rs | |
| parent | eb0f0f73b7da9d76ff6833757fd265725d3e4b14 (diff) | |
| download | fidget_spinner-3a523c3c8ac1bf9094dbe65a6f53b71085438c0c.zip | |
Open the metric unit vocabulary
Diffstat (limited to 'crates/fidget-spinner-store-sqlite/src/lib.rs')
| -rw-r--r-- | crates/fidget-spinner-store-sqlite/src/lib.rs | 19 |
1 files changed, 6 insertions, 13 deletions
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<FrontierStatus, rusqlite::Error> { } fn parse_metric_unit(raw: &str) -> Result<MetricUnit, rusqlite::Error> { - 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<OptimizationObjective, rusqlite::Error> { |