4 releases
0.2.0 | Mar 31, 2024 |
---|---|
0.1.2 | Mar 31, 2024 |
0.1.1 | Mar 31, 2024 |
0.1.0 | Mar 31, 2024 |
#1675 in Parser implementations
36 downloads per month
66KB
1.5K
SLoC
systemd-duration
systemd-duration
is a crate that implements parsing of the systemd duration format in Rust.
This library can convert a systemd duration string to the following:
- std::time::Duration
- time::Duration (available with the
with-time
feature) - chrono::TimeDelta (available with the
with-chrono
feature)
Usage
See the examples directory for code examples.
lib.rs
:
systemd-duration is a library that parses systemd-style durations.
It can parse durations into the following formats:
time::Duration
(with thewith-time
feature)chrono::TimeDelta
(with thewith-chrono
feature)std::time::Duration
It uses the [nom
] library to parse durations.
Example
let td = systemd_duration::stdtime::parse("1d3s").expect("Could not parse duration");
assert_eq!(td, std::time::Duration::from_secs(86403));
Dependencies
~1–2.2MB
~43K SLoC