From 0ed5ef803f1d5a798b18fe2bcb04ac1074e6c4cc Mon Sep 17 00:00:00 2001 From: Dustin Martin Date: Sun, 3 Nov 2024 01:00:07 -0500 Subject: [PATCH] Derive serde traits for Reference Signed-off-by: Dustin Martin --- src/distribution/reference.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/distribution/reference.rs b/src/distribution/reference.rs index eedf0b44b7..8ecdba3476 100644 --- a/src/distribution/reference.rs +++ b/src/distribution/reference.rs @@ -3,6 +3,7 @@ use std::str::FromStr; use std::{convert::TryFrom, sync::OnceLock}; use regex::{Regex, RegexBuilder}; +use serde::{Deserialize, Serialize}; use thiserror::Error; /// NAME_TOTAL_LENGTH_MAX is the maximum total number of characters in a repository name. @@ -72,12 +73,15 @@ pub enum ParseError { /// assert_eq!(Some("latest"), reference.tag()); /// assert_eq!(None, reference.digest()); /// ``` -#[derive(Clone, Hash, PartialEq, Eq, Debug)] +#[derive(Clone, Hash, PartialEq, Eq, Debug, Serialize, Deserialize)] pub struct Reference { registry: String, + #[serde(skip_serializing_if = "Option::is_none")] mirror_registry: Option, repository: String, + #[serde(skip_serializing_if = "Option::is_none")] tag: Option, + #[serde(skip_serializing_if = "Option::is_none")] digest: Option, }