Skip to content

Commit

Permalink
fix: proper metadata parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
somehowchris committed Apr 29, 2022
1 parent e22e92b commit d48a2c4
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 233 deletions.
157 changes: 0 additions & 157 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ itertools = "0.10.3"
serde_json = "1.0.79"
serde = { version = "1.0.136", features = ["derive"] }
rayon = "1.5.2"
validator = { version = "0.14.0", features = ["derive"] }
lazy_static = "1.4.0"
which = "4.2.5"
clap = { version = "3.1.9", features = ["derive", "cargo"] }
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo-all-features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn main() {

// checking if cross is installed
if command_target == CommandTarget::Cross && which::which("cross").is_err() {
println!("{}: Could not find `cross` installed. To install it run `cargo install cross` or header over to https://github.com/cross-rs/cross for more information", Paint::red("error").bold());
println!("{}: Could not find `cross` installed. To install it run `cargo install cross` or head over to https://github.com/cross-rs/cross for more information", Paint::red("error").bold());
process::exit(127);
}

Expand Down
15 changes: 5 additions & 10 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::fmt::{self, Display, Formatter};
use std::io;
use std::process::ExitStatus;
use std::string::FromUtf8Error;
use validator::ValidationError;

/// Enumeration of errors which could be returned by this crate
#[derive(Debug)]
Expand Down Expand Up @@ -48,7 +47,9 @@ pub enum Errors {
},
RustUpNotFound,
IoError(io::Error),
ValidationFailed(ValidationError),
ValidationFailed{
message: String
},
SerdeJsonFailedToParse(serde_json::Error),
CargoNotAvailable,
}
Expand All @@ -72,12 +73,6 @@ impl<T> From<Errors> for Result<T, Errors> {
}
}

/// Implementation of erorrs for `ValidationError`
impl From<ValidationError> for Errors {
fn from(error: ValidationError) -> Self {
Errors::ValidationFailed(error)
}
}

/// Implementation of erorrs for `serde_json::Error`
impl From<serde_json::Error> for Errors {
Expand Down Expand Up @@ -156,8 +151,8 @@ impl Display for Errors {
Self::FailedToParseOutputOfCommand { error } => {
write!(f, "an error ocurred during utf8 parsing. {}", error)
}
Self::ValidationFailed(errors) => {
write!(f, "validation of data failed. {}", errors)
Self::ValidationFailed {message} => {
write!(f, "validation of data failed. {}", message)
}
Self::SerdeJsonFailedToParse(errors) => {
write!(f, "failed to parse json. {}", errors)
Expand Down
3 changes: 1 addition & 2 deletions src/metadata/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::types::FeatureList;
use serde::Deserialize;
use std::collections::HashSet;
use validator::Validate;

#[derive(Clone, Deserialize, Validate)]
#[derive(Clone, Deserialize, Debug)]
pub struct CargoAllFeatures {
pub skip_feature_sets: Option<Vec<FeatureList>>,
pub skip_optional_dependencies: Option<bool>,
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/dependency.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Deserialize;

#[derive(Clone, Deserialize)]
#[derive(Clone, Deserialize, Debug)]
pub struct Dependency {
pub name: String,
pub rename: Option<String>,
Expand Down
Loading

0 comments on commit d48a2c4

Please sign in to comment.