* Copyright (c), Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
*/
pub mod operator;
pub mod om_op;
use serde::Deserialize;
use thiserror::Error;
fn parse_micros_f64<'de, D>(deserializer: D) -> Result<f64, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
if s.starts_with("N/A") {
return Ok(-1.0);
}
let cleaned: String = s
.chars()
.filter(|c| c.is_ascii_digit() || *c == '.' || *c == '-')
.collect();
if cleaned.is_empty() {
return Err(serde::de::Error::custom("empty or invalid number"));
}
cleaned
.parse::<f64>()
.map_err(|_| serde::de::Error::custom("failed to parse as f64"))
}
#[derive(Error, Debug)]
pub enum ParseError {
#[error("CSV format error: {0}")]
CsvError(#[from] csv::Error),
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("File is empty or has invalid data")]
EmptyData,
#[error("The format of file is invalid")]
FormatError,
}