use std::borrow::Cow;
pub struct Metadata {
pub(crate) name: Cow<'static, str>,
pub(crate) version: Cow<'static, str>,
pub(crate) authors: Option<Cow<'static, str>>,
pub(crate) homepage: Option<Cow<'static, str>>,
pub(crate) repository: Option<Cow<'static, str>>,
pub(crate) support: Option<Cow<'static, str>>,
}
impl Metadata {
pub fn new(name: impl Into<Cow<'static, str>>, version: impl Into<Cow<'static, str>>) -> Self {
Self {
name: name.into(),
version: version.into(),
authors: None,
homepage: None,
repository: None,
support: None,
}
}
pub fn authors(mut self, value: impl Into<Cow<'static, str>>) -> Self {
let value = value.into();
if !value.is_empty() {
self.authors = value.into();
}
self
}
pub fn homepage(mut self, value: impl Into<Cow<'static, str>>) -> Self {
let value = value.into();
if !value.is_empty() {
self.homepage = value.into();
}
self
}
pub fn repository(mut self, value: impl Into<Cow<'static, str>>) -> Self {
let value = value.into();
if !value.is_empty() {
self.repository = value.into();
}
self
}
pub fn support(mut self, value: impl Into<Cow<'static, str>>) -> Self {
let value = value.into();
if !value.is_empty() {
self.support = value.into();
}
self
}
}