1- use std:: { error, fmt, io, string} ;
21use std:: fmt:: Display ;
2+ use std:: { error, fmt, io, string} ;
33
44use serde:: de:: { self , Expected , Unexpected } ;
55
@@ -28,6 +28,11 @@ pub enum DecoderError {
2828 UnknownVariant ( String ) ,
2929 // Invalid value
3030 InvalidValue ( String ) ,
31+ // Invalid timestamp
32+ InvalidTimestamp ( i64 ) ,
33+ // Ambiguous timestamp
34+ AmbiguousTimestamp ( i64 ) ,
35+
3136 Unknown ( String ) ,
3237}
3338
@@ -62,6 +67,8 @@ impl fmt::Display for DecoderError {
6267 DecoderError :: UnknownVariant ( ref var) => write ! ( fmt, "unknown variant `{}`" , var) ,
6368 DecoderError :: InvalidValue ( ref desc) => desc. fmt ( fmt) ,
6469 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) ,
6572 }
6673 }
6774}
@@ -83,6 +90,8 @@ impl error::Error for DecoderError {
8390 DecoderError :: UnknownVariant ( _) => "unknown variant" ,
8491 DecoderError :: InvalidValue ( ref desc) => desc,
8592 DecoderError :: Unknown ( ref inner) => inner,
93+ DecoderError :: InvalidTimestamp ( ..) => "no such local time" ,
94+ DecoderError :: AmbiguousTimestamp ( ..) => "ambiguous local time" ,
8695 }
8796 }
8897 fn cause ( & self ) -> Option < & error:: Error > {
0 commit comments