arch_pkg_text/desc/
field.rs1use derive_more::{AsRef, Deref};
2use strum::{AsRefStr, Display, EnumString, IntoStaticStr};
3
4#[derive(Debug, Clone, Copy, Eq, PartialEq)] #[derive(AsRef, Deref, derive_more::Display)] #[display("%{_0}%")]
8pub struct Field<Name>(Name);
9
10impl<Name> Field<Name> {
11 pub const fn name(&self) -> &'_ Name {
13 &self.0
14 }
15
16 pub fn into_name(self) -> Name {
18 self.0
19 }
20}
21
22pub type RawField<'a> = Field<&'a str>;
24
25impl<'a> RawField<'a> {
26 pub const fn name_str(&self) -> &'a str {
28 self.name()
29 }
30}
31
32pub type ParsedField = Field<FieldName>;
34
35impl ParsedField {
36 pub const fn new(name: FieldName) -> Self {
38 Field(name)
39 }
40
41 pub fn name_str(&self) -> &'static str {
43 self.name().into()
44 }
45}
46
47impl From<FieldName> for ParsedField {
48 fn from(value: FieldName) -> Self {
49 ParsedField::new(value)
50 }
51}
52
53#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(AsRefStr, Display, EnumString, IntoStaticStr)] #[strum(use_phf)]
57pub enum FieldName {
58 #[strum(serialize = "FILENAME")]
59 FileName,
60 #[strum(serialize = "NAME")]
61 Name,
62 #[strum(serialize = "BASE")]
63 Base,
64 #[strum(serialize = "VERSION")]
65 Version,
66 #[strum(serialize = "DESC")]
67 Description,
68 #[strum(serialize = "GROUPS")]
69 Groups,
70 #[strum(serialize = "CSIZE")]
71 CompressedSize,
72 #[strum(serialize = "ISIZE")]
73 InstalledSize,
74 #[strum(serialize = "MD5SUM")]
75 Md5Checksum,
76 #[strum(serialize = "SHA256SUM")]
77 Sha256Checksum,
78 #[strum(serialize = "PGPSIG")]
79 PgpSignature,
80 #[strum(serialize = "URL")]
81 Url,
82 #[strum(serialize = "LICENSE")]
83 License,
84 #[strum(serialize = "ARCH")]
85 Architecture,
86 #[strum(serialize = "BUILDDATE")]
87 BuildDate,
88 #[strum(serialize = "PACKAGER")]
89 Packager,
90 #[strum(serialize = "DEPENDS")]
91 Dependencies,
92 #[strum(serialize = "MAKEDEPENDS")]
93 MakeDependencies,
94 #[strum(serialize = "CHECKDEPENDS")]
95 CheckDependencies,
96 #[strum(serialize = "OPTDEPENDS")]
97 OptionalDependencies,
98 #[strum(serialize = "PROVIDES")]
99 Provides,
100 #[strum(serialize = "CONFLICTS")]
101 Conflicts,
102 #[strum(serialize = "REPLACES")]
103 Replaces,
104}
105
106mod parse;
107pub use parse::*;