Skip to content

Commit

Permalink
Add serde support to PackageType
Browse files Browse the repository at this point in the history
This adds both serialization and deserialization to the `PackageType`
enum, based on its lowercase representation.
  • Loading branch information
cd-work committed Dec 17, 2024
1 parent 0d332fa commit b283aa6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions purl/src/package_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::fmt;
use std::str::FromStr;

use phf::phf_map;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use unicase::UniCase;

use crate::{
Expand Down Expand Up @@ -134,6 +136,8 @@ pub type PurlBuilder = GenericPurlBuilder<PackageType>;
///
/// This is a subset of the types described in the PURL spec repository. See
/// [`Purl`] for details.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[non_exhaustive]
pub enum PackageType {
Expand Down

0 comments on commit b283aa6

Please sign in to comment.