Coverage Report

Created: 2022-07-04 16:17

src/serde/duration_millis.rs
Line
Count
Source (jump to first uncovered line)
1
use std::fmt;
2
3
use serde::{
4
    de::{self, Deserializer, Visitor},
5
    ser::{self, Serializer},
6
};
7
use time::Duration;
8
9
1
#[derive(
Debug0
, thiserror::Error)]
Unexecuted instantiation: <obws::serde::duration_millis::Error as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::serde::duration_millis::Error as core::fmt::Debug>::fmt
Unexecuted instantiation: <obws::serde::duration_millis::Error as std::error::Error>::source
Unexecuted instantiation: <obws::serde::duration_millis::Error as core::fmt::Display>::fmt
Unexecuted instantiation: <obws::serde::duration_millis::Error as std::error::Error>::source
<obws::serde::duration_millis::Error as core::fmt::Display>::fmt
Line
Count
Source
9
1
#[derive(Debug, thiserror::Error)]
10
enum Error {
11
    #[error("value is too large for an i64: {0}")]
12
    ValueTooLargeI64(#[source] std::num::TryFromIntError),
13
}
14
15
6
pub fn serialize<S>(value: &Duration, serializer: S) -> Result<S::Ok, S::Error>
16
6
where
17
6
    S: Serializer,
18
6
{
19
6
    let millis = i64::try_from(value.whole_milliseconds())
20
6
        .map_err(|e| 
ser::Error::custom(Error::ValueTooLargeI64(e))0
)
?0
;
Unexecuted instantiation: obws::serde::duration_millis::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::{closure#0}
Unexecuted instantiation: obws::serde::duration_millis::serialize::<_>::{closure#0}
Unexecuted instantiation: obws::serde::duration_millis::serialize::<&mut serde_test::ser::Serializer>::{closure#0}
21
6
    serializer.serialize_i64(millis)
22
6
}
obws::serde::duration_millis::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
15
5
pub fn serialize<S>(value: &Duration, serializer: S) -> Result<S::Ok, S::Error>
16
5
where
17
5
    S: Serializer,
18
5
{
19
5
    let millis = i64::try_from(value.whole_milliseconds())
20
5
        .map_err(|e| ser::Error::custom(Error::ValueTooLargeI64(e)))
?0
;
21
5
    serializer.serialize_i64(millis)
22
5
}
Unexecuted instantiation: obws::serde::duration_millis::serialize::<_>
obws::serde::duration_millis::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
15
1
pub fn serialize<S>(value: &Duration, serializer: S) -> Result<S::Ok, S::Error>
16
1
where
17
1
    S: Serializer,
18
1
{
19
1
    let millis = i64::try_from(value.whole_milliseconds())
20
1
        .map_err(|e| ser::Error::custom(Error::ValueTooLargeI64(e)))
?0
;
21
1
    serializer.serialize_i64(millis)
22
1
}
23
24
45
pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
25
45
where
26
45
    D: Deserializer<'de>,
27
45
{
28
45
    deserializer.deserialize_i64(DurationMillisVisitor)
29
45
}
obws::serde::duration_millis::deserialize::<serde_json::value::Value>
Line
Count
Source
24
22
pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
25
22
where
26
22
    D: Deserializer<'de>,
27
22
{
28
22
    deserializer.deserialize_i64(DurationMillisVisitor)
29
22
}
obws::serde::duration_millis::deserialize::<serde::__private::de::content::ContentDeserializer<serde_json::error::Error>>
Line
Count
Source
24
18
pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
25
18
where
26
18
    D: Deserializer<'de>,
27
18
{
28
18
    deserializer.deserialize_i64(DurationMillisVisitor)
29
18
}
Unexecuted instantiation: obws::serde::duration_millis::deserialize::<_>
Unexecuted instantiation: obws::serde::duration_millis::deserialize::<serde::de::value::SeqAccessDeserializer<serde_test::de::DeserializerSeqVisitor>>
Unexecuted instantiation: obws::serde::duration_millis::deserialize::<serde::de::value::MapAccessDeserializer<serde_test::de::DeserializerMapVisitor>>
obws::serde::duration_millis::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
24
5
pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>
25
5
where
26
5
    D: Deserializer<'de>,
27
5
{
28
5
    deserializer.deserialize_i64(DurationMillisVisitor)
29
5
}
30
31
struct DurationMillisVisitor;
32
33
impl<'de> Visitor<'de> for DurationMillisVisitor {
34
    type Value = Duration;
35
36
0
    fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
37
0
        formatter.write_str("a duration in milliseconds")
38
0
    }
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::expecting
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::expecting
39
40
50
    fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
41
50
    where
42
50
        E: de::Error,
43
50
    {
44
50
        Ok(Duration::milliseconds(v))
45
50
    }
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_i64::<serde_json::error::Error>
Line
Count
Source
40
44
    fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
41
44
    where
42
44
        E: de::Error,
43
44
    {
44
44
        Ok(Duration::milliseconds(v))
45
44
    }
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_i64::<_>
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_i64::<serde_test::error::Error>
Line
Count
Source
40
6
    fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
41
6
    where
42
6
        E: de::Error,
43
6
    {
44
6
        Ok(Duration::milliseconds(v))
45
6
    }
46
47
47
    fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
48
47
    where
49
47
        E: de::Error,
50
47
    {
51
47
        i64::try_from(v)
52
47
            .map_err(|e| 
de::Error::custom(Error::ValueTooLargeI64(e))1
)
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_json::error::Error>::{closure#0}
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<_>::{closure#0}
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_test::error::Error>::{closure#0}
Line
Count
Source
52
1
            .map_err(|e| de::Error::custom(Error::ValueTooLargeI64(e)))
53
47
            .and_then(|v| 
self.visit_i64(v)46
)
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_json::error::Error>::{closure#1}
Line
Count
Source
53
44
            .and_then(|v| self.visit_i64(v))
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<_>::{closure#1}
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_test::error::Error>::{closure#1}
Line
Count
Source
53
2
            .and_then(|v| self.visit_i64(v))
54
47
    }
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_json::error::Error>
Line
Count
Source
47
44
    fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
48
44
    where
49
44
        E: de::Error,
50
44
    {
51
44
        i64::try_from(v)
52
44
            .map_err(|e| de::Error::custom(Error::ValueTooLargeI64(e)))
53
44
            .and_then(|v| self.visit_i64(v))
54
44
    }
Unexecuted instantiation: <obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<_>
<obws::serde::duration_millis::DurationMillisVisitor as serde::de::Visitor>::visit_u64::<serde_test::error::Error>
Line
Count
Source
47
3
    fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
48
3
    where
49
3
        E: de::Error,
50
3
    {
51
3
        i64::try_from(v)
52
3
            .map_err(|e| de::Error::custom(Error::ValueTooLargeI64(e)))
53
3
            .and_then(|v| self.visit_i64(v))
54
3
    }
55
}
56
57
pub mod option {
58
    use super::*;
59
60
4
    pub fn serialize<S>(value: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
61
4
    where
62
4
        S: Serializer,
63
4
    {
64
4
        match value {
65
3
            Some(v) => {
66
3
                let millis = i64::try_from(v.whole_milliseconds())
67
3
                    .map_err(|e| 
ser::Error::custom(Error::ValueTooLargeI64(e))0
)
?0
;
Unexecuted instantiation: obws::serde::duration_millis::option::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>::{closure#0}
Unexecuted instantiation: obws::serde::duration_millis::option::serialize::<_>::{closure#0}
Unexecuted instantiation: obws::serde::duration_millis::option::serialize::<&mut serde_test::ser::Serializer>::{closure#0}
68
3
                serializer.serialize_some(&millis)
69
            }
70
1
            None => serializer.serialize_none(),
71
        }
72
4
    }
obws::serde::duration_millis::option::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>>>
Line
Count
Source
60
2
    pub fn serialize<S>(value: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
61
2
    where
62
2
        S: Serializer,
63
2
    {
64
2
        match value {
65
2
            Some(v) => {
66
2
                let millis = i64::try_from(v.whole_milliseconds())
67
2
                    .map_err(|e| ser::Error::custom(Error::ValueTooLargeI64(e)))
?0
;
68
2
                serializer.serialize_some(&millis)
69
            }
70
0
            None => serializer.serialize_none(),
71
        }
72
2
    }
Unexecuted instantiation: obws::serde::duration_millis::option::serialize::<_>
obws::serde::duration_millis::option::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
60
2
    pub fn serialize<S>(value: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
61
2
    where
62
2
        S: Serializer,
63
2
    {
64
2
        match value {
65
1
            Some(v) => {
66
1
                let millis = i64::try_from(v.whole_milliseconds())
67
1
                    .map_err(|e| ser::Error::custom(Error::ValueTooLargeI64(e)))
?0
;
68
1
                serializer.serialize_some(&millis)
69
            }
70
1
            None => serializer.serialize_none(),
71
        }
72
2
    }
73
74
8
    pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
75
8
    where
76
8
        D: Deserializer<'de>,
77
8
    {
78
8
        deserializer.deserialize_option(DurationMillisOptVisitor)
79
8
    }
obws::serde::duration_millis::option::deserialize::<serde_json::value::Value>
Line
Count
Source
74
4
    pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
75
4
    where
76
4
        D: Deserializer<'de>,
77
4
    {
78
4
        deserializer.deserialize_option(DurationMillisOptVisitor)
79
4
    }
Unexecuted instantiation: obws::serde::duration_millis::option::deserialize::<_>
Unexecuted instantiation: obws::serde::duration_millis::option::deserialize::<serde::de::value::SeqAccessDeserializer<serde_test::de::DeserializerSeqVisitor>>
Unexecuted instantiation: obws::serde::duration_millis::option::deserialize::<serde::de::value::MapAccessDeserializer<serde_test::de::DeserializerMapVisitor>>
obws::serde::duration_millis::option::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
74
4
    pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
75
4
    where
76
4
        D: Deserializer<'de>,
77
4
    {
78
4
        deserializer.deserialize_option(DurationMillisOptVisitor)
79
4
    }
80
81
    struct DurationMillisOptVisitor;
82
83
    impl<'de> Visitor<'de> for DurationMillisOptVisitor {
84
        type Value = Option<Duration>;
85
86
0
        fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
87
0
            formatter.write_str("a duration in milliseconds")
88
0
        }
Unexecuted instantiation: <obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::expecting
Unexecuted instantiation: <obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::expecting
89
90
2
        fn visit_none<E>(self) -> Result<Self::Value, E>
91
2
        where
92
2
            E: de::Error,
93
2
        {
94
2
            Ok(None)
95
2
        }
Unexecuted instantiation: <obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_none::<serde_json::error::Error>
Unexecuted instantiation: <obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_none::<_>
<obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_none::<serde_test::error::Error>
Line
Count
Source
90
2
        fn visit_none<E>(self) -> Result<Self::Value, E>
91
2
        where
92
2
            E: de::Error,
93
2
        {
94
2
            Ok(None)
95
2
        }
96
97
6
        fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
98
6
        where
99
6
            D: Deserializer<'de>,
100
6
        {
101
6
            deserializer
102
6
                .deserialize_i64(DurationMillisVisitor)
103
6
                .map(Some)
104
6
        }
<obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_some::<serde_json::value::Value>
Line
Count
Source
97
4
        fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
98
4
        where
99
4
            D: Deserializer<'de>,
100
4
        {
101
4
            deserializer
102
4
                .deserialize_i64(DurationMillisVisitor)
103
4
                .map(Some)
104
4
        }
Unexecuted instantiation: <obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_some::<_>
<obws::serde::duration_millis::option::DurationMillisOptVisitor as serde::de::Visitor>::visit_some::<&mut serde_test::de::Deserializer>
Line
Count
Source
97
2
        fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
98
2
        where
99
2
            D: Deserializer<'de>,
100
2
        {
101
2
            deserializer
102
2
                .deserialize_i64(DurationMillisVisitor)
103
2
                .map(Some)
104
2
        }
105
    }
106
107
    #[cfg(test)]
108
    mod tests {
109
        use serde::{Deserialize, Serialize};
110
        use serde_test::{assert_de_tokens_error, assert_tokens, Token};
111
        use time::Duration;
112
113
17
        #[derive(
Debug0
,
PartialEq4
,
Seri2
aliz2
e2
,
D13
ese
rializ0
e)]
Unexecuted instantiation: <obws::serde::duration_millis::option::tests::SimpleDuration as core::cmp::PartialEq>::ne
<obws::serde::duration_millis::option::tests::SimpleDuration as core::cmp::PartialEq>::eq
Line
Count
Source
113
4
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
<obws::serde::duration_millis::option::tests::SimpleDuration as serde::ser::Serialize>::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
113
2
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
113
2
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<serde::de::value::MapAccessDeserializer<serde_test::de::DeserializerMapVisitor>>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::expecting
<<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
113
4
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_str::<serde_test::error::Error>
Line
Count
Source
113
4
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::expecting
<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
113
4
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
113
5
        #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde::de::value::StrDeserializer<serde_test::error::Error>>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::<serde_test::de::EnumMapVisitor>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde::de::value::U32Deserializer<serde_test::error::Error>>
Unexecuted instantiation: <<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::__DeserializeWith as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_u64::<serde_test::error::Error>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde_test::de::BytesDeserializer>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::<serde_test::de::DeserializerSeqVisitor>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_bytes::<serde_test::error::Error>
Unexecuted instantiation: <<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::<serde_test::de::DeserializerSeqVisitor>::{closure#0}
<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::<serde_test::de::DeserializerMapVisitor>
Line
Count
Source
113
9
        #[derive(Debug, PartialEq, Serialize, 
D5
eserialize)]
Unexecuted instantiation: <<<obws::serde::duration_millis::option::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<serde::de::value::SeqAccessDeserializer<serde_test::de::DeserializerSeqVisitor>>
114
        struct SimpleDuration {
115
            #[serde(with = "super")]
116
            value: Option<Duration>,
117
        }
118
119
1
        #[test]
120
1
        fn roundtrip() {
121
1
            assert_tokens(
122
1
                &SimpleDuration {
123
1
                    value: Some(Duration::milliseconds(150)),
124
1
                },
125
1
                &[
126
1
                    Token::Struct {
127
1
                        name: "SimpleDuration",
128
1
                        len: 1,
129
1
                    },
130
1
                    Token::Str("value"),
131
1
                    Token::Some,
132
1
                    Token::I64(150),
133
1
                    Token::StructEnd,
134
1
                ],
135
1
            );
136
1
137
1
            assert_tokens(
138
1
                &SimpleDuration { value: None },
139
1
                &[
140
1
                    Token::Struct {
141
1
                        name: "SimpleDuration",
142
1
                        len: 1,
143
1
                    },
144
1
                    Token::Str("value"),
145
1
                    Token::None,
146
1
                    Token::StructEnd,
147
1
                ],
148
1
            );
149
1
        }
150
151
1
        #[test]
152
1
        fn deser() {
153
1
            assert_de_tokens_error::<SimpleDuration>(
154
1
                &[
155
1
                    Token::Struct {
156
1
                        name: "SimpleDuration",
157
1
                        len: 0,
158
1
                    },
159
1
                    Token::StructEnd,
160
1
                ],
161
1
                "missing field `value`",
162
1
            );
163
1
        }
164
    }
165
}
166
167
#[cfg(test)]
168
mod tests {
169
    use serde::{Deserialize, Serialize};
170
    use serde_test::{assert_de_tokens, assert_de_tokens_error, assert_tokens, Token};
171
    use time::Duration;
172
173
20
    #[derive(
Debug0
,
PartialEq4
,
Seri1
aliz1
e1
,
D15
ese
rializ0
e)]
Unexecuted instantiation: <obws::serde::duration_millis::tests::SimpleDuration as core::cmp::PartialEq>::ne
<obws::serde::duration_millis::tests::SimpleDuration as core::cmp::PartialEq>::eq
Line
Count
Source
173
4
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
<<obws::serde::duration_millis::tests::SimpleDuration as serde::ser::Serialize>::serialize::__SerializeWith as serde::ser::Serialize>::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
173
1
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
<obws::serde::duration_millis::tests::SimpleDuration as serde::ser::Serialize>::serialize::<&mut serde_test::ser::Serializer>
Line
Count
Source
173
1
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<serde::de::value::MapAccessDeserializer<serde_test::de::DeserializerMapVisitor>>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::expecting
<<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
173
5
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::<serde_test::de::DeserializerMapVisitor>
Line
Count
Source
173
10
    #[derive(Debug, PartialEq, Serialize, 
D5
eserialize)]
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde::de::value::U32Deserializer<serde_test::error::Error>>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_bytes::<serde_test::error::Error>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde::de::value::StrDeserializer<serde_test::error::Error>>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_u64::<serde_test::error::Error>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::expecting
<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
173
5
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::<serde_test::de::EnumMapVisitor>
Unexecuted instantiation: <<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::__DeserializeWith as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::<&mut serde_test::de::Deserializer>
Line
Count
Source
173
5
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__FieldVisitor as serde::de::Visitor>::visit_str::<serde_test::error::Error>
Line
Count
Source
173
5
    #[derive(Debug, PartialEq, Serialize, Deserialize)]
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::<serde_test::de::DeserializerSeqVisitor>::{closure#0}
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_seq::<serde_test::de::DeserializerSeqVisitor>
Unexecuted instantiation: <<<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Visitor as serde::de::Visitor>::visit_map::__DeserializeWith as serde::de::Deserialize>::deserialize::<serde::de::value::SeqAccessDeserializer<serde_test::de::DeserializerSeqVisitor>>
Unexecuted instantiation: <<obws::serde::duration_millis::tests::SimpleDuration as serde::de::Deserialize>::deserialize::__Field as serde::de::Deserialize>::deserialize::<serde_test::de::BytesDeserializer>
174
    struct SimpleDuration {
175
        #[serde(with = "super")]
176
        value: Duration,
177
    }
178
179
1
    #[test]
180
1
    fn roundtrip() {
181
1
        assert_tokens(
182
1
            &SimpleDuration {
183
1
                value: Duration::milliseconds(150),
184
1
            },
185
1
            &[
186
1
                Token::Struct {
187
1
                    name: "SimpleDuration",
188
1
                    len: 1,
189
1
                },
190
1
                Token::Str("value"),
191
1
                Token::I64(150),
192
1
                Token::StructEnd,
193
1
            ],
194
1
        );
195
1
    }
196
197
1
    #[test]
198
1
    fn deser() {
199
1
        assert_de_tokens(
200
1
            &SimpleDuration {
201
1
                value: Duration::milliseconds(150),
202
1
            },
203
1
            &[
204
1
                Token::Struct {
205
1
                    name: "SimpleDuration",
206
1
                    len: 1,
207
1
                },
208
1
                Token::Str("value"),
209
1
                Token::U64(150),
210
1
                Token::StructEnd,
211
1
            ],
212
1
        );
213
1
214
1
        assert_de_tokens_error::<SimpleDuration>(
215
1
            &[
216
1
                Token::Struct {
217
1
                    name: "SimpleDuration",
218
1
                    len: 1,
219
1
                },
220
1
                Token::Str("value"),
221
1
                Token::U64(u64::MAX),
222
1
                Token::StructEnd,
223
1
            ],
224
1
            "value is too large for an i64: \
225
1
            out of range integral type conversion attempted",
226
1
        );
227
1
    }
228
}