I'm writing a fairly simple REST api, one of my objects will want to know a time of day and duration to be activated. I'm hoping I can serialize an ISO 8601 Time/Duration into a data members of a struct in rust using actix-web, serde and chrono, is this possible?
I've done some initial research into serde serilization and chrono, but I'm not finding much other than very basic datetime serialization. Not quite what I want to do.
Anything is possible, of course, but in this case you will have to do some of the lifting yourself or using another crate, because chrono's
Durationtype doesn't provide formatting or parsing utilities.You can implement the time half quite easily. Note that chrono doesn't have a "time with timezone" type, so I will use
NaiveTimeand assume UTC.format_durationis a placeholder function that should format the duration appropriately. You might consider looking into the iso8601-duration crate.