diff --git a/src/helpers/github.rs b/src/helpers/github.rs index 842a26b..b504735 100644 --- a/src/helpers/github.rs +++ b/src/helpers/github.rs @@ -569,10 +569,13 @@ impl MetadataSource for GitHubReleaseAsset { } #[allow(dead_code)] -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum GitHubKind { + #[serde(rename="github/repo")] Repo, + #[serde(rename="github/star")] Star, + #[serde(rename="github/release")] Release, } @@ -594,30 +597,6 @@ impl GitHubKind { } } -impl serde::Serialize for GitHubKind { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} - -impl<'de> serde::Deserialize<'de> for GitHubKind { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let s: &str = serde::Deserialize::deserialize(deserializer)?; - match s { - "github/repo" => Ok(GitHubKind::Repo), - "github/star" => Ok(GitHubKind::Star), - "github/release" => Ok(GitHubKind::Release), - _ => Err(serde::de::Error::custom(format!("Invalid kind: {}", s))), - } - } -} - #[cfg(test)] mod tests { use std::path::PathBuf;