1
1
use std:: collections:: HashMap ;
2
2
3
3
use git_repository as git;
4
+ use smartstring:: alias:: String as SmolString ;
4
5
use std:: fmt;
5
6
use std:: hash:: { Hash , Hasher } ;
6
7
@@ -72,19 +73,33 @@ impl fmt::Display for Change {
72
73
}
73
74
}
74
75
76
+ /// Section in which a dependency was defined in.
77
+ #[ derive(
78
+ Debug , Copy , Clone , serde:: Serialize , serde:: Deserialize , Eq , PartialEq , Hash , Ord , PartialOrd ,
79
+ ) ]
80
+ #[ serde( rename_all = "lowercase" ) ]
81
+ pub enum DependencyKind {
82
+ /// Used for production builds.
83
+ Normal ,
84
+ /// Used only for tests and examples.
85
+ Dev ,
86
+ /// Used in build scripts.
87
+ Build ,
88
+ }
89
+
75
90
/// Pack all information we know about a change made to a version of a crate.
76
91
#[ derive( Default , Clone , serde:: Serialize , serde:: Deserialize , Eq , PartialEq , Debug ) ]
77
92
pub struct CrateVersion {
78
93
/// The crate name, i.e. `clap`.
79
- pub name : String ,
94
+ pub name : SmolString ,
80
95
/// is the release yanked?
81
96
pub yanked : bool ,
82
97
/// The semantic version of the crate.
83
98
#[ serde( rename = "vers" ) ]
84
- pub version : String ,
99
+ pub version : SmolString ,
85
100
/// The checksum over the crate archive
86
- #[ serde( rename = "cksum" ) ]
87
- pub checksum : String ,
101
+ #[ serde( rename = "cksum" , with = "hex" ) ]
102
+ pub checksum : [ u8 ; 32 ] ,
88
103
/// All cargo features
89
104
pub features : HashMap < String , Vec < String > > ,
90
105
/// All crate dependencies
@@ -109,20 +124,23 @@ impl CrateVersion {
109
124
) ]
110
125
pub struct Dependency {
111
126
/// The crate name
112
- pub name : String ,
127
+ pub name : SmolString ,
113
128
/// The version the parent crate requires of this dependency
114
129
#[ serde( rename = "req" ) ]
115
- pub required_version : String ,
130
+ pub required_version : SmolString ,
116
131
/// All cargo features configured by the parent crate
117
132
pub features : Vec < String > ,
118
133
/// True if this is an optional dependency
119
134
pub optional : bool ,
120
135
/// True if default features are enabled
121
136
pub default_features : bool ,
122
137
/// The name of the build target
123
- pub target : Option < String > ,
138
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
139
+ pub target : Option < SmolString > ,
124
140
/// The kind of dependency, usually 'normal' or 'dev'
125
- pub kind : Option < String > ,
141
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
142
+ pub kind : Option < DependencyKind > ,
126
143
/// The package this crate is contained in
127
- pub package : Option < String > ,
144
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
145
+ pub package : Option < SmolString > ,
128
146
}
0 commit comments