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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Raw-preserving service capability declarations.
use crate::source::SourceSpan;
use super::Located;
fn is_exact_candidate(value: &str) -> bool {
!value.is_empty() && !value.chars().any(char::is_whitespace)
}
/// One exact service capability name from `cap_add`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CapabilityAddItem {
raw: Located<String>,
}
impl CapabilityAddItem {
pub(crate) const fn new(raw: Located<String>) -> Self {
Self { raw }
}
/// Returns the exact authored string value.
#[must_use]
pub fn value(&self) -> &str {
self.raw.value()
}
/// Returns the exact source span of this sequence item.
#[must_use]
pub const fn span(&self) -> SourceSpan {
self.raw.span()
}
/// Reports whether this value is a conservative future cross-format exact candidate.
///
/// This classification is purely lexical: the value must be non-empty and contain no
/// whitespace. It does not normalize case or consult a capability whitelist or target.
#[must_use]
pub fn is_exact_candidate(&self) -> bool {
is_exact_candidate(self.value())
}
}
/// An explicitly authored `cap_add` sequence, including an explicit empty sequence.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CapabilityAdd {
span: SourceSpan,
items: Vec<CapabilityAddItem>,
}
impl CapabilityAdd {
pub(crate) const fn new(span: SourceSpan, items: Vec<CapabilityAddItem>) -> Self {
Self { span, items }
}
/// Returns the exact span of the authored sequence value.
#[must_use]
pub const fn span(&self) -> SourceSpan {
self.span
}
/// Returns items in authored order, including exact duplicates.
#[must_use]
pub fn items(&self) -> &[CapabilityAddItem] {
&self.items
}
}
/// One exact service capability name from `cap_drop`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CapabilityDropItem {
raw: Located<String>,
}
impl CapabilityDropItem {
pub(crate) const fn new(raw: Located<String>) -> Self {
Self { raw }
}
/// Returns the exact authored string value.
#[must_use]
pub fn value(&self) -> &str {
self.raw.value()
}
/// Returns the exact source span of this sequence item.
#[must_use]
pub const fn span(&self) -> SourceSpan {
self.raw.span()
}
/// Reports whether this value is a conservative future cross-format exact candidate.
///
/// This classification is purely lexical: the value must be non-empty and contain no
/// whitespace. It does not normalize case or consult a capability whitelist or target.
#[must_use]
pub fn is_exact_candidate(&self) -> bool {
is_exact_candidate(self.value())
}
}
/// An explicitly authored `cap_drop` sequence, including an explicit empty sequence.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CapabilityDrop {
span: SourceSpan,
items: Vec<CapabilityDropItem>,
}
impl CapabilityDrop {
pub(crate) const fn new(span: SourceSpan, items: Vec<CapabilityDropItem>) -> Self {
Self { span, items }
}
/// Returns the exact span of the authored sequence value.
#[must_use]
pub const fn span(&self) -> SourceSpan {
self.span
}
/// Returns items in authored order, including exact duplicates.
#[must_use]
pub fn items(&self) -> &[CapabilityDropItem] {
&self.items
}
}