[PATCH proxmox v2 11/25] time: use u64 parse helper from nom

Lukas Wagner
2026-03-19T09:46:57Z

...instead of our own implementation.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
Tested-by: Arthur Bied-Charreton <a.bied-charreton@proxmox.com>
---
proxmox-time/src/parse_helpers.rs | 5 -----
proxmox-time/src/time_span.rs | 4 ++--
2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/proxmox-time/src/parse_helpers.rs b/proxmox-time/src/parse_helpers.rs
index 5c46a9d5..d2ca9d10 100644
--- a/proxmox-time/src/parse_helpers.rs
+++ b/proxmox-time/src/parse_helpers.rs
@@ -21,11 +21,6 @@ pub(crate) fn parse_error<'a>(
nom::Err::Error(err)
}

-// Parse a 64 bit unsigned integer
-pub(crate) fn parse_u64(i: &str) -> IResult<&str, u64> {
- map_res(recognize(digit1), str::parse)(i)
-}
-
// Parse complete input, generate simple error message (use this for simple line input).
pub(crate) fn parse_complete_line<'a, F, O>(what: &str, i: &'a str, parser: F) -> Result<O, Error>
where
diff --git a/proxmox-time/src/time_span.rs b/proxmox-time/src/time_span.rs
index c3c47f44..951e82e5 100644
--- a/proxmox-time/src/time_span.rs
+++ b/proxmox-time/src/time_span.rs
@@ -117,7 +117,7 @@

use anyhow::{Context, Error};

-use crate::parse_helpers::{parse_complete_line, parse_error, parse_u64, IResult};
+use crate::parse_helpers::{parse_complete_line, parse_error, IResult};

// Seconds-per-unit constants. Month and year are the systemd definitions:
// 1 month = 30.44 days = 2,630,016 s (exact), 1 year = 365.25 days = 31,557,600 s (exact).
@@ -776,7 +776,7 @@ fn parse_time_span_incomplete(mut i: &str) -> IResult<&str, TimeSpanParts> {
if i.is_empty() {
break;
}
- let (n, num) = parse_u64(i)?;
+ let (n, num) = nom::character::complete::u64(i)?;
i = n.trim_start();
parsed_any = true;

--
2.47.3