This repository was archived by the owner on Nov 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -879,6 +879,46 @@ impl serde::Serialize for ImportMultiRescanSince {
879879 }
880880}
881881
882+ impl < ' de > serde:: Deserialize < ' de > for ImportMultiRescanSince {
883+ fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
884+ where
885+ D : serde:: Deserializer < ' de > ,
886+ {
887+ use serde:: de;
888+ use std:: fmt;
889+ struct Visitor ;
890+ impl < ' de > de:: Visitor < ' de > for Visitor {
891+ type Value = ImportMultiRescanSince ;
892+
893+ fn expecting ( & self , formatter : & mut fmt:: Formatter ) -> fmt:: Result {
894+ write ! ( formatter, "unix timestamp or 'now'" )
895+ }
896+
897+ fn visit_u64 < E > ( self , value : u64 ) -> Result < Self :: Value , E >
898+ where
899+ E : de:: Error ,
900+ {
901+ Ok ( ImportMultiRescanSince :: Timestamp ( value) )
902+ }
903+
904+ fn visit_str < E > ( self , value : & str ) -> Result < Self :: Value , E >
905+ where
906+ E : de:: Error ,
907+ {
908+ if value == "now" {
909+ Ok ( ImportMultiRescanSince :: Now )
910+ } else {
911+ Err ( de:: Error :: custom ( format ! (
912+ "invalid str '{}', expecting 'now' or unix timestamp" ,
913+ value
914+ ) ) )
915+ }
916+ }
917+ }
918+ deserializer. deserialize_any ( Visitor )
919+ }
920+ }
921+
882922impl Default for ImportMultiRescanSince {
883923 fn default ( ) -> Self {
884924 ImportMultiRescanSince :: Timestamp ( 0 )
You can’t perform that action at this time.
0 commit comments