mago_codex/metadata/
flags.rs1use serde::Deserialize;
2use serde::Serialize;
3
4bitflags::bitflags! {
5 #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
6 #[non_exhaustive]
7 pub struct MetadataFlags: u64 {
8 const ABSTRACT = 1 << 0;
9 const FINAL = 1 << 1;
10 const READONLY = 1 << 3;
11 const DEPRECATED = 1 << 4;
12 const ENUM_INTERFACE = 1 << 5;
13 const POPULATED = 1 << 6;
14 const INTERNAL = 1 << 7;
15 const CONSISTENT_CONSTRUCTOR = 1 << 11;
16 const CONSISTENT_TEMPLATES = 1 << 12;
17 const UNCHECKED = 1 << 13;
18 const USER_DEFINED = 1 << 14;
19 const BUILTIN = 1 << 15;
20 const HAS_YIELD = 1 << 16;
21 const MUST_USE = 1 << 17;
22 const HAS_THROW = 1 << 18;
23 const PURE = 1 << 19;
24 const IGNORE_NULLABLE_RETURN = 1 << 20;
25 const IGNORE_FALSABLE_RETURN = 1 << 21;
26 const INHERITS_DOCS = 1 << 22;
27 const NO_NAMED_ARGUMENTS = 1 << 23;
28 const BACKED_ENUM_CASE = 1 << 24;
29 const UNIT_ENUM_CASE = 1 << 25;
30 const BY_REFERENCE = 1 << 26;
31 const VARIADIC = 1 << 27;
32 const PROMOTED_PROPERTY = 1 << 28;
33 const HAS_DEFAULT = 1 << 29;
34 const VIRTUAL_PROPERTY = 1 << 30;
35 const ASYMMETRIC_PROPERTY = 1 << 31;
36 const STATIC = 1 << 32;
37 const WRITEONLY = 1 << 33;
38 const MAGIC_PROPERTY = 1 << 34;
39 const MAGIC_METHOD = 1 << 35;
40 const API = 1 << 36;
41 }
42}
43
44impl MetadataFlags {
46 #[inline]
47 #[must_use]
48 pub const fn is_deprecated(self) -> bool {
49 self.contains(Self::DEPRECATED)
50 }
51
52 #[inline]
53 #[must_use]
54 pub const fn is_abstract(self) -> bool {
55 self.contains(Self::ABSTRACT)
56 }
57
58 #[inline]
59 #[must_use]
60 pub const fn is_final(self) -> bool {
61 self.contains(Self::FINAL)
62 }
63
64 #[inline]
65 #[must_use]
66 pub const fn has_yield(self) -> bool {
67 self.contains(Self::HAS_YIELD)
68 }
69
70 #[inline]
71 #[must_use]
72 pub const fn must_use(self) -> bool {
73 self.contains(Self::MUST_USE)
74 }
75
76 #[inline]
77 #[must_use]
78 pub const fn is_pure(self) -> bool {
79 self.contains(Self::PURE)
80 }
81
82 #[inline]
83 #[must_use]
84 pub const fn has_consistent_constructor(self) -> bool {
85 self.contains(Self::CONSISTENT_CONSTRUCTOR)
86 }
87
88 #[inline]
89 #[must_use]
90 pub const fn has_consistent_templates(self) -> bool {
91 self.contains(Self::CONSISTENT_TEMPLATES)
92 }
93
94 #[inline]
95 #[must_use]
96 pub const fn is_user_defined(self) -> bool {
97 self.contains(Self::USER_DEFINED)
98 }
99
100 #[inline]
101 #[must_use]
102 pub const fn is_built_in(self) -> bool {
103 self.contains(Self::BUILTIN)
104 }
105
106 #[inline]
107 #[must_use]
108 pub const fn is_internal(self) -> bool {
109 self.contains(Self::INTERNAL)
110 }
111
112 #[inline]
113 #[must_use]
114 pub const fn is_populated(self) -> bool {
115 self.contains(Self::POPULATED)
116 }
117
118 #[inline]
119 #[must_use]
120 pub const fn is_readonly(self) -> bool {
121 self.contains(Self::READONLY)
122 }
123
124 #[inline]
125 #[must_use]
126 pub const fn is_writeonly(self) -> bool {
127 self.contains(Self::WRITEONLY)
128 }
129
130 #[inline]
131 #[must_use]
132 pub const fn is_enum_interface(self) -> bool {
133 self.contains(Self::ENUM_INTERFACE)
134 }
135
136 #[inline]
137 #[must_use]
138 pub const fn is_unchecked(self) -> bool {
139 self.contains(Self::UNCHECKED)
140 }
141
142 #[inline]
143 #[must_use]
144 pub const fn ignore_nullable_return(self) -> bool {
145 self.contains(Self::IGNORE_NULLABLE_RETURN)
146 }
147
148 #[inline]
149 #[must_use]
150 pub const fn ignore_falsable_return(self) -> bool {
151 self.contains(Self::IGNORE_FALSABLE_RETURN)
152 }
153
154 #[inline]
155 #[must_use]
156 pub const fn inherits_docs(self) -> bool {
157 self.contains(Self::INHERITS_DOCS)
158 }
159
160 #[inline]
161 #[must_use]
162 pub const fn forbids_named_arguments(self) -> bool {
163 self.contains(Self::NO_NAMED_ARGUMENTS)
164 }
165
166 #[inline]
167 #[must_use]
168 pub const fn has_throw(self) -> bool {
169 self.contains(Self::HAS_THROW)
170 }
171
172 #[inline]
173 #[must_use]
174 pub const fn is_backed_enum_case(self) -> bool {
175 self.contains(Self::BACKED_ENUM_CASE)
176 }
177
178 #[inline]
179 #[must_use]
180 pub const fn is_unit_enum_case(self) -> bool {
181 self.contains(Self::UNIT_ENUM_CASE)
182 }
183
184 #[inline]
185 #[must_use]
186 pub const fn is_by_reference(self) -> bool {
187 self.contains(Self::BY_REFERENCE)
188 }
189
190 #[inline]
191 #[must_use]
192 pub const fn is_variadic(self) -> bool {
193 self.contains(Self::VARIADIC)
194 }
195
196 #[inline]
197 #[must_use]
198 pub const fn is_promoted_property(self) -> bool {
199 self.contains(Self::PROMOTED_PROPERTY)
200 }
201
202 #[inline]
203 #[must_use]
204 pub const fn has_default(self) -> bool {
205 self.contains(Self::HAS_DEFAULT)
206 }
207
208 #[inline]
209 #[must_use]
210 pub const fn is_virtual_property(self) -> bool {
211 self.contains(Self::VIRTUAL_PROPERTY)
212 }
213
214 #[inline]
215 #[must_use]
216 pub const fn is_magic_property(self) -> bool {
217 self.contains(Self::MAGIC_PROPERTY)
218 }
219
220 #[inline]
221 #[must_use]
222 pub const fn is_magic_method(self) -> bool {
223 self.contains(Self::MAGIC_METHOD)
224 }
225
226 #[inline]
227 #[must_use]
228 pub const fn is_asymmetric_property(self) -> bool {
229 self.contains(Self::ASYMMETRIC_PROPERTY)
230 }
231
232 #[inline]
233 #[must_use]
234 pub const fn is_static(self) -> bool {
235 self.contains(Self::STATIC)
236 }
237
238 #[inline]
239 #[must_use]
240 pub const fn is_public_api(self) -> bool {
241 self.contains(Self::API)
242 }
243}