Skip to content

add dedicated parsing and printing routines for std::time::Duration, along with jiff::fmt::serde helpers #298

@LukeMathWalker

Description

@LukeMathWalker

I've migrated Pavex, the web framework I'm working on, to jiff in this commit.
Things went pretty smoothly, the documentation was excellent all around.

There was only one instance that had me thinking "this could be better": this hunk. Graceful shutdown timeouts, time-to-live for sessions—these are all values that must be modelled as positive durations. I have therefore relied on std::time::Duration rather than jiff's SignedDuration.
Nonetheless, I want to give users the possibility to pass these configuration values using a human-readable format (e.g. 2 minutes), a job I used to delegate to the humantime crate.

I wonder: would it possible for jiff to add facilities to parse std::time::Duration in the same way it currently parses SignedDuration?
I'm naively assuming that:

  • Most of the parsing logic would be identical, sign aside
  • It would show up as an additional module (e.g. std_duration?) under jiff::fmt::serde.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions