| Crates.io | duration-flex |
| lib.rs | duration-flex |
| version | 0.2.0 |
| created_at | 2024-12-24 15:48:37.066318+00 |
| updated_at | 2024-12-25 15:44:06.215682+00 |
| description | Specify durations in an easier to easy format, like 1h20m. |
| homepage | https://github.com/vgobbo/duration-flex?tab=readme-ov-file#duration-flex |
| repository | https://github.com/vgobbo/duration-flex?tab=readme-ov-file |
| max_upload_size | |
| id | 1494008 |
| size | 18,793 |
Helper class to make it easier to specify durations. Specially useful in configuration files.
It is common for durations to be specified in configuration files as "the number of seconds", which might not be very readable in some cases.
This crate aims to help solving this problem by allowing the time unit to be specified alongside the amount of time.
Example:
1h23m1w6d23h49m59sSimply call one of the from methods to create an instance:
use duration_flex::DurationFlex;
pub fn main() {
let df = DurationFlex::try_from("1w6d23h49m59s").unwrap();
println!("{df}");
}
clap: enable clap support, so it can be used as application arguments.serde: enable serde support.