Skip to content

Commit

Permalink
Derive serde traits for Reference
Browse files Browse the repository at this point in the history
Signed-off-by: Dustin Martin <[email protected]>
  • Loading branch information
dmartin committed Nov 3, 2024
1 parent cabfc64 commit 0ed5ef8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/distribution/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<String>,
repository: String,
#[serde(skip_serializing_if = "Option::is_none")]
tag: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
digest: Option<String>,
}

Expand Down

0 comments on commit 0ed5ef8

Please sign in to comment.