1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::constant::*;
/// PkgInfo Field key. See [crate::marshalling::Field::KEY] for more information.
///
/// Communication with build scripts includes keys within shell script strings. Keys
/// must not contain shell-sensitive string-escaping characters.
#[derive(Clone, Copy)]
#[repr(u8)]
pub enum PkgKey {
Arch = b'a',
Backup = b'b',
Depend = b'-', // Component of other fields; never directly serialized
Depends = b'D',
License = b'l',
Filepath = b'_', // Component of other fields; never directly serialized
MakeBin = b'M', // Component of other fields; never directly serialized
RepoPath = b'R',
MakeArchs = b'A',
MakeBins = b'B',
MakeDepends = b'm',
PkgDesc = b'd',
PkgName = b'n',
PkgVer = b'v',
Homepage = b'h',
}
impl std::fmt::Display for PkgKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// String representation of keys may be embedded within shell strings, and thus must not
// contain shell-string escaping characters.
debug_assert!(!SHELL_SPECIAL_CHARS.contains(&self.as_char()));
write!(f, "{}", self.as_char())
}
}
impl PkgKey {
pub const fn as_char(&self) -> char {
*self as u8 as char
}
}