use crate::api::ParamValue;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum LinkType {
#[default]
Other,
Runbook,
Image,
Package,
}
impl LinkType {
pub(in super::super) fn as_str(self) -> &'static str {
match self {
Self::Other => "other",
Self::Runbook => "runbook",
Self::Image => "image",
Self::Package => "package",
}
}
}
impl ParamValue<'static> for LinkType {
fn as_value(&self) -> std::borrow::Cow<'static, str> {
self.as_str().into()
}
}
#[cfg(test)]
mod tests {
use crate::api::projects::releases::links::LinkType;
#[test]
fn link_type_as_str() {
let items = &[
(LinkType::Other, "other"),
(LinkType::Runbook, "runbook"),
(LinkType::Image, "image"),
(LinkType::Package, "package"),
];
for (i, s) in items {
assert_eq!(i.as_str(), *s);
}
}
#[test]
fn link_type_default() {
assert_eq!(LinkType::default(), LinkType::Other);
}
}