feat: Remove api module and relocate handlers, clean up unused code and dead_code attributes

- Delete api.rs module containing 20+ handler functions (credit management, subscriber accounts, rating plans, user blocking, system stats, metrics, engine control, error stats, sync control, health checks)
- Remove dead_code attributes from UsageEvent and UsageType in charging/types
- Remove validate_imsi helper function and dead_code attribute from errors/helpers
- Remove ConfigurationError logging case
This commit is contained in:
nutcas3
2026-04-25 02:37:42 +03:00
parent 231f03c903
commit dcd1cdeca0
8 changed files with 2 additions and 473 deletions
@@ -68,23 +68,6 @@ pub fn validate_bytes(bytes: u64) -> ChargingResult<()> {
Ok(())
}
#[allow(dead_code)]
pub fn validate_imsi(imsi: &str) -> ChargingResult<()> {
if imsi.is_empty() {
return Err(ChargingError::InvalidInput("IMSI cannot be empty".to_string()));
}
if imsi.len() < 15 || imsi.len() > 15 {
return Err(ChargingError::InvalidInput("IMSI must be exactly 15 digits".to_string()));
}
if !imsi.chars().all(|c| c.is_ascii_digit()) {
return Err(ChargingError::InvalidInput("IMSI must contain only digits".to_string()));
}
Ok(())
}
pub fn validate_session_id(session_id: &str) -> ChargingResult<()> {
if session_id.is_empty() {
return Err(ChargingError::InvalidInput("Session ID cannot be empty".to_string()));
@@ -161,9 +144,6 @@ pub fn log_error(error: &ChargingError) {
ChargingError::SerializationError(msg) => {
tracing::error!("Serialization error: {}", msg);
}
ChargingError::ConfigurationError(msg) => {
tracing::error!("Configuration error: {}", msg);
}
ChargingError::InternalError(msg) => {
tracing::error!("Internal error: {}", msg);
}
-4
View File
@@ -13,8 +13,6 @@ pub enum ChargingError {
UsageBlocked(String),
InvalidInput(String),
SerializationError(String),
#[allow(dead_code)]
ConfigurationError(String),
InternalError(String),
}
@@ -31,7 +29,6 @@ impl fmt::Display for ChargingError {
ChargingError::UsageBlocked(reason) => write!(f, "Usage blocked: {}", reason),
ChargingError::InvalidInput(msg) => write!(f, "Invalid input: {}", msg),
ChargingError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
ChargingError::ConfigurationError(msg) => write!(f, "Configuration error: {}", msg),
ChargingError::InternalError(msg) => write!(f, "Internal error: {}", msg),
}
}
@@ -52,7 +49,6 @@ impl IntoResponse for ChargingError {
ChargingError::UsageBlocked(reason) => (StatusCode::FORBIDDEN, reason),
ChargingError::InvalidInput(msg) => (StatusCode::BAD_REQUEST, msg),
ChargingError::SerializationError(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg),
ChargingError::ConfigurationError(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg),
ChargingError::InternalError(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg),
};