refactor: refactor kernel common to have better code

This commit is contained in:
2026-07-22 11:57:56 +08:00
parent 5bfdfb71c2
commit 3dd8275787
5 changed files with 87 additions and 179 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ use crate::cli::{AppConfig, AppResolver};
use anyhow::Result;
use lcrconn::{
BfsResolver, DeviceKind, LutResolver, Request, Resolver, Response, ResponsePriority,
common::{Circuit, CircuitDeviceScale, JointKind, sanitize_device_value, sanitize_floating_point},
common::{Circuit, CircuitDeviceScale, JointKind, validate_device_value, validate_floating_point},
dataset::{DatasetCollection, from_human_readable_value, to_human_readable_value},
query::MAX_RESPONSE_CNT,
};
@@ -310,7 +310,7 @@ impl App {
let value = self.parse_plain_float(pct_str, |x| *x >= 0.0 && *x <= 100.0);
value
.map(|v| v / 100.0 * target_value)
.map(|v| sanitize_device_value(v))
.map(|v| validate_device_value(v))
.transpose()
.ok()
.flatten()
@@ -349,7 +349,7 @@ impl App {
Ok(value) => value,
Err(_) => return None,
};
let value = sanitize_floating_point(value).ok()?;
let value = validate_floating_point(value).ok()?;
if checker(&value) { Some(value) } else { None }
}