1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use serde::{Deserialize, Deserializer};
use semver::VersionReq;
#[derive(PartialEq, Clone, Debug, Copy, Deserialize)]
pub enum DependencyKind {
#[serde(rename = "normal")]
Normal,
#[serde(rename = "dev")]
Development,
#[serde(rename = "build")]
Build,
#[doc(hidden)]
DoNotMatchExhaustively,
}
impl Default for DependencyKind {
fn default() -> DependencyKind {
DependencyKind::Normal
}
}
fn parse_dependency_kind<'de, D>(d: D) -> Result<DependencyKind, D::Error>
where
D: Deserializer<'de>,
{
Deserialize::deserialize(d).map(|x: Option<_>| x.unwrap_or_default())
}
#[derive(Clone, Deserialize, Debug)]
pub struct Dependency {
pub name: String,
pub source: Option<String>,
pub req: VersionReq,
#[serde(deserialize_with = "parse_dependency_kind")]
pub kind: DependencyKind,
pub optional: bool,
uses_default_features: bool,
features: Vec<String>,
target: Option<String>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}