@@ -535,15 +535,13 @@ pub struct EncodableDependency {
535
535
/// The serialization for `SourceId` doesn't do URL encode for parameters.
536
536
/// In contrast, this type is aware of that whenever [`ResolveVersion`] allows
537
537
/// us to do so (v4 or later).
538
- #[ derive( Deserialize , Debug , PartialOrd , Ord , Clone ) ]
539
- #[ serde( transparent) ]
538
+ #[ derive( Debug , PartialOrd , Ord , Clone ) ]
540
539
pub struct EncodableSourceId {
541
540
inner : SourceId ,
542
541
/// We don't care about the deserialization of this, as the `url` crate
543
542
/// will always decode as the URL was encoded. Only when a [`Resolve`]
544
543
/// turns into a [`EncodableResolve`] will it set the value accordingly
545
544
/// via [`encodable_source_id`].
546
- #[ serde( skip) ]
547
545
encoded : bool ,
548
546
}
549
547
@@ -592,6 +590,20 @@ impl ser::Serialize for EncodableSourceId {
592
590
}
593
591
}
594
592
593
+ impl < ' de > de:: Deserialize < ' de > for EncodableSourceId {
594
+ fn deserialize < D > ( d : D ) -> Result < Self , D :: Error >
595
+ where
596
+ D : de:: Deserializer < ' de > ,
597
+ {
598
+ let s = String :: deserialize ( d) ?;
599
+ let sid = SourceId :: from_url ( & s) . map_err ( de:: Error :: custom) ?;
600
+ Ok ( EncodableSourceId {
601
+ inner : sid,
602
+ encoded : false ,
603
+ } )
604
+ }
605
+ }
606
+
595
607
impl std:: hash:: Hash for EncodableSourceId {
596
608
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
597
609
self . inner . hash ( state)
0 commit comments