Skip to content

Commit 77e7273

Browse files
committed
add more fields to SerializedDependency
1 parent 616e144 commit 77e7273

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/cargo/core/dependency.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,29 @@ pub struct Dependency {
3333

3434

3535
#[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>,
3946
}
4047

4148
impl Encodable for Dependency {
4249
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
4350
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(),
4659
}.encode(s)
4760
}
4861
}
@@ -54,6 +67,16 @@ pub enum Kind {
5467
Build,
5568
}
5669

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+
5780
impl DependencyInner {
5881
/// Attempt to create a `Dependency` from an entry in the manifest.
5982
pub fn parse(name: &str,
@@ -235,4 +258,3 @@ impl Dependency {
235258
self.inner.matches_id(id)
236259
}
237260
}
238-

0 commit comments

Comments
 (0)