fn deserialize_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
    D: Deserializer<'de>,
{
    struct DurationVisitor;

    impl<'de> Visitor<'de> for DurationVisitor {
        type Value = Duration;

        fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            formatter.write_str("u64 or a duration")
        }

        fn visit_i64<E>(self, value: i64) -> Result<Duration, E>
        where
            E: de::Error,
        {
            self.visit_u64(value as u64)
        }

        fn visit_u64<E>(self, value: u64) -> Result<Duration, E>
        where
            E: de::Error,
        {
            Ok(Duration::from_millis(Deserialize::deserialize(
                value.into_deserializer(),
            )?))
        }

        fn visit_str<E>(self, value: &str) -> Result<Duration, E>
        where
            E: de::Error,
        {
            humantime_serde::deserialize(value.into_deserializer())
        }
    }

    deserializer.deserialize_any(DurationVisitor)
}
// custom function is defined to deserialize based on whether field contains a pre 0.9.0
// u64 interpreted as milliseconds or proper duration introduced in 0.9.0
//
// TODO: when we get to refactoring down the line, this code can just be removed
// and all Duration fields could just have #[serde(with = "humantime_serde")] instead
// reason for that is that we don't expect anyone to be upgrading from pre 0.9.0 when we have,
// for argument sake, 0.11.0 out
custom function is defined to deserialize based on whether field contains a pre 0.9.0
u64 interpreted as milliseconds or proper duration introduced in 0.9.0

when we get to refactoring down the line, this code can just be removed
and all Duration fields could just have #[serde(with = "humantime_serde")] instead
reason for that is that we don't expect anyone to be upgrading from pre 0.9.0 when we have,
for argument sake, 0.11.0 out
custom function is defined to deserialize based on whether field contains a pre 0 . 9 . 0 u64 interpreted as milliseconds or proper duration introduced in 0 . 9 . 0 when we get to refactoring down the line this code can just be removed and all Duration fields could just have # [ serde ( with = " humantime_serde " ) ] instead reason for that is that we don ' t expect anyone to be upgrading from pre 0 . 9 . 0 when we have for argument sake 0 . 11 . 0 out
fn deserialize_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
    D: Deserializer<'de>,
{
    struct DurationVisitor;
    impl<'de> Visitor<'de> for DurationVisitor {
        type Value = Duration;
        fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            formatter.write_str("u64 or a duration")
        }
        fn visit_i64<E>(self, value: i64) -> Result<Duration, E>
        where
            E: de::Error,
        {
            self.visit_u64(value as u64)
        }
        fn visit_u64<E>(self, value: u64) -> Result<Duration, E>
        where
            E: de::Error,
        {
            Ok(Duration::from_millis(Deserialize::deserialize(
                value.into_deserializer(),
            )?))
        }
        fn visit_str<E>(self, value: &str) -> Result<Duration, E>
        where
            E: de::Error,
        {
            humantime_serde::deserialize(value.into_deserializer())
        }
    }
    deserializer.deserialize_any(DurationVisitor)
}
fn deserialize_duration < ' de , D > ( deserializer : D ) -> Result < Duration , D :: Error > where D : Deserializer < ' de > , { struct DurationVisitor ; impl < ' de > Visitor < ' de > for DurationVisitor { type Value = Duration ; fn expecting ( & self , formatter : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result { formatter . write_str ( " " ) } fn visit_i64 < E > ( self , value : i64 ) -> Result < Duration , E > where E : de :: Error , { self . visit_u64 ( value as u64 ) } fn visit_u64 < E > ( self , value : u64 ) -> Result < Duration , E > where E : de :: Error , { Ok ( Duration :: from_millis ( Deserialize :: deserialize ( value . into_deserializer ( ) , ) ? ) ) } fn visit_str < E > ( self , value : & str ) -> Result < Duration , E > where E : de :: Error , { humantime_serde :: deserialize ( value . into_deserializer ( ) ) } } deserializer . deserialize_any ( DurationVisitor ) }
custom function is defined to deserialize based on whether field contains a pre 0.9.0
u64 interpreted as milliseconds or proper duration introduced in 0.9.0
custom function is defined to deserialize based on whether field contains a pre 0 . 9 . 0 u64 interpreted as milliseconds or proper duration introduced in 0 . 9 . 0
deserializer
D
deserializer
D