toml-rs / toml

Rust TOML Parser
https://docs.rs/toml
Apache License 2.0
688 stars 103 forks source link

Time doesn't implement Serialize and Deserialize #696

Open dev-ardi opened 6 months ago

dev-ardi commented 6 months ago

I would expect time to convert pretty naturally to std::time::Duration but that's not the case

epage commented 6 months ago

A Duration is serialized as seconds and nanoseconds and is meant to be a "time since" something

A Time is a "time of day" which is a different unit and would not be interchangeable. If we added serialize/deserialzie support, it would be to allow exclusively serializing/deserializing as just a Time and not a full DateTime.,

dev-ardi commented 6 months ago

Right not Time has no serde implementation, which makes it impossible to use if you're using serde. While it is a "time of day" it can be used as a duration too, if you interpret it that way!

execute_command_in = 00:10:10

can mean a duration indeed.

I'm not pushing for Duration specifically even if it makes sense for me, it was just an idea. I'm fine if it deserializes into a toml::Value::Time, and then if it makes sense we can impl Into<Duration> for Time

epage commented 6 months ago

I'm fine with serde support for those all of the date/time types but Duration I am against Duration for now.

dev-ardi commented 6 months ago

Are you against deserializing into Duration or having an impl Into<Duration> for Time

epage commented 6 months ago

Both.