Skip to content

Commit

Permalink
Add some more fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jan 5, 2019
1 parent 9229180 commit 5206ab4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use serde::{Deserialize, Deserializer};
use semver::VersionReq;
use std::fmt;

#[derive(PartialEq, Clone, Debug, Copy, Serialize, Deserialize)]
/// Dependencies can come in three kinds
Expand Down Expand Up @@ -51,8 +52,29 @@ pub struct Dependency {
/// The list of features enabled for this dependency.
pub features: Vec<String>,
/// The target this dependency is specific to.
target: Option<String>,
///
/// Use the [`Display`] trait to access the contents.
///
/// [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
pub target: Option<Platform>,
/// If the dependency is renamed, this is the new name for the dependency
/// as a string. None if it is not renamed.
pub rename: Option<String>,
/// The URL of the index of the registry where this dependency is from.
///
/// If None, the dependency is from crates.io.
pub registry: Option<String>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
}

/// A target platform.
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Platform(String);

impl fmt::Display for Platform {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ pub struct Package {
/// ```
#[serde(default)]
pub metadata: serde_json::Value,
/// The name of a native library the package is linking to.
pub links: Option<String>,
#[doc(hidden)]
#[serde(skip)]
__do_not_match_exhaustively: (),
Expand Down

0 comments on commit 5206ab4

Please sign in to comment.