Skip to content

Commit

Permalink
FromStr instead of PackageUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
koa committed Oct 29, 2023
1 parent 0d9e9f5 commit 610247a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cyclonedx-bom/src/external_models/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ impl Validate for Purl {
}
}

impl<'a> From<PackageUrl<'a>> for Purl {
fn from(value: PackageUrl<'a>) -> Self {
Self(value.to_string())
impl FromStr for Purl {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(s.to_string()))
}
}

Expand Down Expand Up @@ -116,10 +117,12 @@ pub enum UriError {

#[cfg(test)]
mod test {
use super::*;
use crate::validation::FailureReason;
use pretty_assertions::assert_eq;

use crate::validation::FailureReason;

use super::*;

#[test]
fn valid_purls_should_pass_validation() {
let validation_result = Purl("pkg:cargo/cyclonedx-bom@0.3.1".to_string())
Expand Down

0 comments on commit 610247a

Please sign in to comment.