You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the serde of a Duration exposes its internal representation, and is not very convenient for a human to read. In Nyx, I had to resort to adding the following methods to serde Epoch and Duration to be human readable:
pub(crate)fnduration_to_str<S>(duration:&Duration,serializer:S) -> Result<S::Ok,S::Error>whereS:Serializer,{
serializer.serialize_str(&format!("{duration}"))}/// A deserializer from Duration stringpub(crate)fnduration_from_str<'de,D>(deserializer:D) -> Result<Duration,D::Error>whereD:Deserializer<'de>,{// implementation of the custom deserialization functionlet s = String::deserialize(deserializer)?;Duration::from_str(&s).map_err(serde::de::Error::custom)}
This should be the default behavior of serde for Duration and Epoch.
This is a breaking change because it will break the current serde users.
The text was updated successfully, but these errors were encountered:
At the moment, the
serde
of a Duration exposes its internal representation, and is not very convenient for a human to read. In Nyx, I had to resort to adding the following methods toserde
Epoch and Duration to be human readable:This should be the default behavior of serde for Duration and Epoch.
This is a breaking change because it will break the current serde users.
The text was updated successfully, but these errors were encountered: