Skip to content

Commit

Permalink
Remove my unneeded URL serde
Browse files Browse the repository at this point in the history
I didn't realize URL crate had a serde feature
  • Loading branch information
mlieberman85 committed Dec 14, 2023
1 parent d587226 commit d60c322
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
syn = "2.0.15"
typify = "0.0.14"
url = "2.2"
url = { version = "2.2", features = ["serde"] }

[dev-dependencies]
maplit = "1.0.2"
Expand Down
3 changes: 1 addition & 2 deletions src/models/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pub mod b64_option_serde;
pub mod url_serde;
pub mod b64_option_serde;
122 changes: 0 additions & 122 deletions src/models/helpers/url_serde.rs

This file was deleted.

7 changes: 2 additions & 5 deletions src/models/intoto/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This module provides structs for the SLSAProvenanceV1Predicate and its related structures.
//! It also includes the necessary (de)serialization code for handling SLSA provenance predicates.

use crate::models::helpers::{b64_option_serde, url_serde};
use crate::models::helpers::b64_option_serde;
use chrono::{DateTime, Utc};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand All @@ -22,7 +22,7 @@ pub struct SLSAProvenanceV1Predicate {
/// A structure representing the build definition of the SLSA Provenance v1 Predicate.
#[derive(Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
pub struct BuildDefinition {
#[serde(rename = "buildType", with = "url_serde")]
#[serde(rename = "buildType")]
#[schemars(with = "Url")]
pub build_type: Url,
#[serde(rename = "externalParameters")]
Expand Down Expand Up @@ -52,7 +52,6 @@ pub struct RunDetails {
/// A structure representing the builder information of the SLSA Provenance v1 Predicate.
#[derive(Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
pub struct Builder {
#[serde(with = "url_serde")]
#[schemars(with = "Url")]
pub id: Url,
#[serde(
Expand Down Expand Up @@ -81,7 +80,6 @@ pub struct BuildMetadata {
/// A size-efficient description of any software artifact or resource (mutable or immutable).
#[derive(Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
pub struct ResourceDescriptor {
#[serde(with = "url_serde")]
#[schemars(with = "Url")]
/// A URI used to identify the resource or artifact globally. This field is REQUIRED unless either digest or content is set.
pub uri: Url,
Expand All @@ -93,7 +91,6 @@ pub struct ResourceDescriptor {
pub name: Option<String>,
#[serde(
rename = "downloadLocation",
with = "url_serde",
default,
skip_serializing_if = "Option::is_none"
)]
Expand Down
9 changes: 4 additions & 5 deletions src/models/intoto/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ use url::Url;
use std::fmt::Debug;

use crate::models::{
helpers::url_serde,
intoto::predicate::{deserialize_predicate, Predicate},
};

/// Represents an In-Toto v1 statement.
#[derive(Debug, Serialize, PartialEq, JsonSchema)]
pub struct InTotoStatementV1<T: Debug + Serialize + PartialEq + JsonSchema = Predicate> {
#[serde(rename = "_type", with = "url_serde")]
#[serde(rename = "_type")]
#[schemars(with = "Url")]
pub _type: Url,
pub subject: Vec<Subject>,
#[serde(rename = "predicateType", with = "url_serde")]
#[serde(rename = "predicateType")]
#[schemars(with = "Url")]
pub predicate_type: Url,
pub predicate: T,
Expand Down Expand Up @@ -75,10 +74,10 @@ impl<'de> Deserialize<'de> for InTotoStatementV1 {
// Helper struct to deserialize the JSON before constructing the InTotoStatementV1.
#[derive(Deserialize)]
struct Helper {
#[serde(rename = "_type", with = "url_serde")]
#[serde(rename = "_type")]
_type: Url,
subject: Vec<Subject>,
#[serde(rename = "predicateType", with = "url_serde")]
#[serde(rename = "predicateType")]
predicate_type: Url,
predicate: Value,
}
Expand Down

0 comments on commit d60c322

Please sign in to comment.