@@ -33,16 +33,29 @@ pub struct Dependency {
33
33
34
34
35
35
#[ derive( RustcEncodable ) ]
36
- struct SerializedDependency {
37
- name : String ,
38
- req : String
36
+ struct SerializedDependency < ' a > {
37
+ name : & ' a str ,
38
+ source : & ' a SourceId ,
39
+ req : String ,
40
+ kind : Kind ,
41
+
42
+ optional : bool ,
43
+ uses_default_features : bool ,
44
+ features : & ' a [ String ] ,
45
+ target : & ' a Option < & ' a str > ,
39
46
}
40
47
41
48
impl Encodable for Dependency {
42
49
fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
43
50
SerializedDependency {
44
- name : self . name ( ) . to_string ( ) ,
45
- req : self . version_req ( ) . to_string ( )
51
+ name : self . name ( ) ,
52
+ source : & self . source_id ( ) ,
53
+ req : self . version_req ( ) . to_string ( ) ,
54
+ kind : self . kind ( ) ,
55
+ optional : self . is_optional ( ) ,
56
+ uses_default_features : self . uses_default_features ( ) ,
57
+ features : self . features ( ) ,
58
+ target : & self . only_for_platform ( ) ,
46
59
} . encode ( s)
47
60
}
48
61
}
@@ -54,6 +67,16 @@ pub enum Kind {
54
67
Build ,
55
68
}
56
69
70
+ impl Encodable for Kind {
71
+ fn encode < S : Encoder > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > {
72
+ match * self {
73
+ Kind :: Normal => None ,
74
+ Kind :: Development => Some ( "dev" ) ,
75
+ Kind :: Build => Some ( "build" ) ,
76
+ } . encode ( s)
77
+ }
78
+ }
79
+
57
80
impl DependencyInner {
58
81
/// Attempt to create a `Dependency` from an entry in the manifest.
59
82
pub fn parse ( name : & str ,
@@ -235,4 +258,3 @@ impl Dependency {
235
258
self . inner . matches_id ( id)
236
259
}
237
260
}
238
-
0 commit comments