1use std::fmt;
8
9#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct Family(std::borrow::Cow<'static, str>);
16
17impl Family {
18 pub const NODE: Family = Family(std::borrow::Cow::Borrowed("node"));
20 pub const RUST: Family = Family(std::borrow::Cow::Borrowed("rust"));
22 pub const PYTHON: Family = Family(std::borrow::Cow::Borrowed("python"));
24 pub const GO: Family = Family(std::borrow::Cow::Borrowed("go"));
26 pub const JVM: Family = Family(std::borrow::Cow::Borrowed("jvm"));
28 pub const DOTNET: Family = Family(std::borrow::Cow::Borrowed("dotnet"));
30 pub const PHP: Family = Family(std::borrow::Cow::Borrowed("php"));
32 pub const RUBY: Family = Family(std::borrow::Cow::Borrowed("ruby"));
34
35 pub fn new(name: impl Into<std::borrow::Cow<'static, str>>) -> Self {
37 Family(name.into())
38 }
39
40 pub fn as_str(&self) -> &str {
42 &self.0
43 }
44
45 pub fn display(&self) -> &str {
47 match self.as_str() {
48 "node" => "Node / frontend",
49 "rust" => "Rust",
50 "python" => "Python",
51 "go" => "Go",
52 "jvm" => "JVM",
53 "dotnet" => ".NET",
54 "php" => "PHP",
55 "ruby" => "Ruby",
56 other => other,
57 }
58 }
59}
60
61impl fmt::Display for Family {
62 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
63 f.write_str(self.as_str())
64 }
65}
66
67impl From<&'static str> for Family {
68 fn from(s: &'static str) -> Self {
69 Family::new(s)
70 }
71}
72
73impl AsRef<str> for Family {
74 fn as_ref(&self) -> &str {
75 self.as_str()
76 }
77}