@@ -208,6 +208,8 @@ pub struct EncodableCrate {
208208 // NOTE: Used by shields.io, altering `downloads` requires a PR with shields.io
209209 pub downloads : i64 ,
210210 pub recent_downloads : Option < i64 > ,
211+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
212+ pub default_version : Option < String > ,
211213 // NOTE: Used by shields.io, altering `max_version` requires a PR with shields.io
212214 pub max_version : String ,
213215 pub newest_version : String , // Most recently updated version, which may not be max
@@ -224,6 +226,7 @@ impl EncodableCrate {
224226 #[ allow( clippy:: too_many_arguments) ]
225227 pub fn from (
226228 krate : Crate ,
229+ default_version : Option < & str > ,
227230 top_versions : Option < & TopVersions > ,
228231 versions : Option < Vec < i32 > > ,
229232 keywords : Option < & [ Keyword ] > ,
@@ -254,6 +257,8 @@ impl EncodableCrate {
254257 let documentation = remove_blocked_urls ( documentation) ;
255258 let repository = remove_blocked_urls ( repository) ;
256259
260+ let default_version = default_version. map ( ToString :: to_string) ;
261+
257262 let max_version = top_versions
258263 . and_then ( |v| v. highest . as_ref ( ) )
259264 . map ( |v| v. to_string ( ) )
@@ -289,6 +294,7 @@ impl EncodableCrate {
289294 keywords : keyword_ids,
290295 categories : category_ids,
291296 badges,
297+ default_version,
292298 max_version,
293299 newest_version,
294300 max_stable_version,
@@ -310,6 +316,7 @@ impl EncodableCrate {
310316
311317 pub fn from_minimal (
312318 krate : Crate ,
319+ default_version : Option < & str > ,
313320 top_versions : Option < & TopVersions > ,
314321 badges : Option < Vec < ( ) > > ,
315322 exact_match : bool ,
@@ -318,6 +325,7 @@ impl EncodableCrate {
318325 ) -> Self {
319326 Self :: from (
320327 krate,
328+ default_version,
321329 top_versions,
322330 None ,
323331 None ,
@@ -800,6 +808,7 @@ mod tests {
800808 . unwrap ( ) ,
801809 downloads : 0 ,
802810 recent_downloads : None ,
811+ default_version : None ,
803812 max_version : "" . to_string ( ) ,
804813 newest_version : "" . to_string ( ) ,
805814 max_stable_version : None ,
0 commit comments