use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MetadataTag {
pub key: String,
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub tag_type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
impl MetadataTag {
pub fn new(key: impl Into<String>) -> Self {
Self {
key: key.into(),
tag_type: None,
value: None,
}
}
pub fn with_value(key: impl Into<String>, value: impl Into<String>) -> Self {
Self {
key: key.into(),
tag_type: None,
value: Some(value.into()),
}
}
#[must_use]
pub fn with_type(mut self, tag_type: impl Into<String>) -> Self {
self.tag_type = Some(tag_type.into());
self
}
}