use crate::error::InventoryError;
pub fn validate_time_range<Time: Copy + TryInto<u32>>(
start_time: Time,
end_time: Time,
) -> Result<(), InventoryError> {
let start: u32 = start_time.try_into().map_err(|_| {
InventoryError::Internal("Failed to convert start_time to u32".to_string())
})?;
let end: u32 = end_time.try_into().map_err(|_| {
InventoryError::Internal("Failed to convert end_time to u32".to_string())
})?;
if end <= start {
return Err(InventoryError::InvalidTimeRange);
}
if end >= 2400 {
return Err(InventoryError::Internal("Time must be less than 2400".to_string()));
}
Ok(())
}