Skip to content

Commit

Permalink
Resolve clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Jan 9, 2024
1 parent c0c797b commit 58adcd1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<(), io::Error> {
let mut entries = vec![];

for line in io::BufReader::new(file).lines().flatten() {
let entry: nixtract::NixtractEntry = serde_json::from_str(&line.trim()).unwrap();
let entry: nixtract::NixtractEntry = serde_json::from_str(line.trim()).unwrap();
entries.push(entry);
}
let nixtract: Nixtract = Nixtract { entries };
Expand Down
12 changes: 6 additions & 6 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ pub(crate) struct ModelDependency {
pub(crate) depends_on: Vec<String>,
}

impl Into<String> for ModelType {
fn into(self) -> String {
match self {
impl From<ModelType> for String {
fn from(val: ModelType) -> Self {
match val {
ModelType::Application => "application".to_owned(),
}
}
}

impl Into<String> for ModelExternalReferenceType {
fn into(self) -> String {
match self {
impl From<ModelExternalReferenceType> for String {
fn from(val: ModelExternalReferenceType) -> Self {
match val {
ModelExternalReferenceType::Website => "website".to_owned(),
}
}
Expand Down
38 changes: 26 additions & 12 deletions src/nixtract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
//! - Parsing the incoming output of Nixtract
//! - Converting that input into the internal representation of Genealogos
// In this module, one might see that we do deserialize unused fields. This is
// to ensure we stay complient with nixtract output.

use serde::Deserialize;

use crate::model::{
Expand All @@ -17,34 +20,43 @@ pub(crate) struct Nixtract {

#[derive(Deserialize, Debug)]
pub(crate) struct NixtractEntry {
pub(crate) attribute_path: String,
pub(crate) derivation_path: String,
#[serde(rename(deserialize = "attribute_path"))]
pub(crate) _attribute_path: String,
#[serde(rename(deserialize = "derivation_path"))]
pub(crate) _derivation_path: String,
pub(crate) output_path: String,
pub(crate) outputs: Vec<NixtractOutput>,
pub(crate) name: String,
#[serde(rename(deserialize = "outputs"))]
pub(crate) _outputs: Vec<NixtractOutput>,
#[serde(rename(deserialize = "name"))]
pub(crate) _name: String,
pub(crate) parsed_name: NixtractParsedName,
pub(crate) nixpkgs_metadata: NixtractNixpkgsMetadata,
pub(crate) build_inputs: Vec<NixtractBuiltInput>,
}

#[derive(Deserialize, Debug)]
pub(crate) struct NixtractOutput {
pub(crate) name: String,
pub(crate) output_path: String,
#[serde(rename(deserialize = "name"))]
pub(crate) _name: String,
#[serde(rename(deserialize = "output_path"))]
pub(crate) _output_path: String,
}

#[derive(Deserialize, Debug)]
pub(crate) struct NixtractParsedName {
pub(crate) name: String,
pub(crate) version: String,
#[serde(rename(deserialize = "version"))]
pub(crate) _version: String,
}

#[derive(Deserialize, Debug)]
pub(crate) struct NixtractNixpkgsMetadata {
pub(crate) description: String,
pub(crate) pname: String,
#[serde(rename(deserialize = "pname"))]
pub(crate) _pname: String,
pub(crate) version: String,
pub(crate) broken: bool,
#[serde(rename(deserialize = "broken"))]
pub(crate) _broken: bool,
pub(crate) homepage: String,
pub(crate) licenses: Option<Vec<NixtractLicense>>,
}
Expand All @@ -58,8 +70,10 @@ pub(crate) struct NixtractLicense {

#[derive(Deserialize, Debug)]
pub(crate) struct NixtractBuiltInput {
pub(crate) attribute_path: String,
pub(crate) build_input_type: String,
#[serde(rename(deserialize = "attribute_path"))]
pub(crate) _attribute_path: String,
#[serde(rename(deserialize = "build_input_type"))]
pub(crate) _build_input_type: String,
pub(crate) output_path: Option<String>,
}

Expand All @@ -83,7 +97,7 @@ impl From<Nixtract> for Model {
.nixpkgs_metadata
.licenses
.as_ref()
.map(|v| v.into_iter().map(Into::into).collect());
.map(|v| v.iter().map(Into::into).collect());

ModelComponent {
r#type: ModelType::Application,
Expand Down

0 comments on commit 58adcd1

Please sign in to comment.