Skip to content

Commit

Permalink
Merge pull request #250 from dmartin/reference-serde
Browse files Browse the repository at this point in the history
Derive serde traits for Reference
  • Loading branch information
flavio authored Nov 4, 2024
2 parents 3472870 + 0ed5ef8 commit 5245936
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 5245936

Please sign in to comment.