1
- use std:: { error, fmt, io, string} ;
2
1
use std:: fmt:: Display ;
2
+ use std:: { error, fmt, io, string} ;
3
3
4
4
use serde:: de:: { self , Expected , Unexpected } ;
5
5
@@ -28,6 +28,11 @@ pub enum DecoderError {
28
28
UnknownVariant ( String ) ,
29
29
// Invalid value
30
30
InvalidValue ( String ) ,
31
+ // Invalid timestamp
32
+ InvalidTimestamp ( i64 ) ,
33
+ // Ambiguous timestamp
34
+ AmbiguousTimestamp ( i64 ) ,
35
+
31
36
Unknown ( String ) ,
32
37
}
33
38
@@ -62,6 +67,8 @@ impl fmt::Display for DecoderError {
62
67
DecoderError :: UnknownVariant ( ref var) => write ! ( fmt, "unknown variant `{}`" , var) ,
63
68
DecoderError :: InvalidValue ( ref desc) => desc. fmt ( fmt) ,
64
69
DecoderError :: Unknown ( ref inner) => inner. fmt ( fmt) ,
70
+ DecoderError :: InvalidTimestamp ( ref i) => write ! ( fmt, "no such local time {}" , i) ,
71
+ DecoderError :: AmbiguousTimestamp ( ref i) => write ! ( fmt, "ambiguous local time {}" , i) ,
65
72
}
66
73
}
67
74
}
@@ -83,6 +90,8 @@ impl error::Error for DecoderError {
83
90
DecoderError :: UnknownVariant ( _) => "unknown variant" ,
84
91
DecoderError :: InvalidValue ( ref desc) => desc,
85
92
DecoderError :: Unknown ( ref inner) => inner,
93
+ DecoderError :: InvalidTimestamp ( ..) => "no such local time" ,
94
+ DecoderError :: AmbiguousTimestamp ( ..) => "ambiguous local time" ,
86
95
}
87
96
}
88
97
fn cause ( & self ) -> Option < & error:: Error > {
0 commit comments