Skip to content

Commit 0e5b4e3

Browse files
authored
Merge pull request #8 from ischaojie/serde-default
Can deserializing using serde_json with default value
2 parents 19f2f1f + 7b96653 commit 0e5b4e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/metadata.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ pub struct Metadata {
1818
pub version: String,
1919
/// A Platform specification describing an operating system supported by the distribution
2020
/// which is not listed in the “Operating System” Trove classifiers.
21+
#[cfg_attr(feature = "serde", serde(default))]
2122
pub platforms: Vec<String>,
2223
/// Binary distributions containing a PKG-INFO file will use the Supported-Platform field
2324
/// in their metadata to specify the OS and CPU for which the binary distribution was compiled.
25+
#[cfg_attr(feature = "serde", serde(default))]
2426
pub supported_platforms: Vec<String>,
2527
/// A one-line summary of what the distribution does.
2628
pub summary: Option<String>,
@@ -40,13 +42,17 @@ pub struct Metadata {
4042
/// Text indicating the license covering the distribution where the license is not a selection from the `License` Trove classifiers.
4143
pub license: Option<String>,
4244
/// Each entry is a string giving a single classification value for the distribution.
45+
#[cfg_attr(feature = "serde", serde(default))]
4346
pub classifiers: Vec<String>,
4447
/// Each entry contains a string naming some other distutils project required by this distribution.
48+
#[cfg_attr(feature = "serde", serde(default))]
4549
pub requires_dist: Vec<String>,
4650
/// Each entry contains a string naming a Distutils project which is contained within this distribution.
51+
#[cfg_attr(feature = "serde", serde(default))]
4752
pub provides_dist: Vec<String>,
4853
/// Each entry contains a string describing a distutils project’s distribution which this distribution renders obsolete,
4954
/// meaning that the two projects should not be installed at the same time.
55+
#[cfg_attr(feature = "serde", serde(default))]
5056
pub obsoletes_dist: Vec<String>,
5157
/// A string containing the maintainer’s name at a minimum; additional contact information may be provided.
5258
///
@@ -62,16 +68,20 @@ pub struct Metadata {
6268
/// This field specifies the Python version(s) that the distribution is guaranteed to be compatible with.
6369
pub requires_python: Option<String>,
6470
/// Each entry contains a string describing some dependency in the system that the distribution is to be used.
71+
#[cfg_attr(feature = "serde", serde(default))]
6572
pub requires_external: Vec<String>,
6673
/// A string containing a browsable URL for the project and a label for it, separated by a comma.
74+
#[cfg_attr(feature = "serde", serde(default))]
6775
pub project_urls: Vec<String>,
6876
/// A string containing the name of an optional feature. Must be a valid Python identifier.
6977
/// May be used to make a dependency conditional on whether the optional feature has been requested.
78+
#[cfg_attr(feature = "serde", serde(default))]
7079
pub provides_extras: Vec<String>,
7180
/// A string stating the markup syntax (if any) used in the distribution’s description,
7281
/// so that tools can intelligently render the description.
7382
pub description_content_type: Option<String>,
7483
/// A string containing the name of another core metadata field.
84+
#[cfg_attr(feature = "serde", serde(default))]
7585
pub dynamic: Vec<String>,
7686
}
7787

0 commit comments

Comments
 (0)