use serde::{Deserialize, Serialize};
use serde_json::{Map, Value as JsonValue};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ArtifactRef {
pub kind: String,
pub uri: String,
pub hash: Option<String>,
pub summary: Option<String>,
pub metadata: JsonValue,
}
impl ArtifactRef {
pub fn new(kind: impl Into<String>, uri: impl Into<String>) -> Self {
Self {
kind: kind.into(),
uri: uri.into(),
hash: None,
summary: None,
metadata: JsonValue::Object(Map::new()),
}
}
pub fn with_hash(mut self, hash: impl Into<String>) -> Self {
self.hash = Some(hash.into());
self
}
pub fn with_summary(mut self, summary: impl Into<String>) -> Self {
self.summary = Some(summary.into());
self
}
pub fn with_metadata(mut self, metadata: JsonValue) -> Self {
self.metadata = metadata;
self
}
}