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 }
41}
42
43impl MetadataFlags {
45 #[inline]
46 #[must_use]
47 pub const fn is_deprecated(self) -> bool {
48 self.contains(Self::DEPRECATED)
49 }
50
51 #[inline]
52 #[must_use]
53 pub const fn is_abstract(self) -> bool {
54 self.contains(Self::ABSTRACT)
55 }
56
57 #[inline]
58 #[must_use]
59 pub const fn is_final(self) -> bool {
60 self.contains(Self::FINAL)
61 }
62
63 #[inline]
64 #[must_use]
65 pub const fn has_yield(self) -> bool {
66 self.contains(Self::HAS_YIELD)
67 }
68
69 #[inline]
70 #[must_use]
71 pub const fn must_use(self) -> bool {
72 self.contains(Self::MUST_USE)
73 }
74
75 #[inline]
76 #[must_use]
77 pub const fn is_pure(self) -> bool {
78 self.contains(Self::PURE)
79 }
80
81 #[inline]
82 #[must_use]
83 pub const fn has_consistent_constructor(self) -> bool {
84 self.contains(Self::CONSISTENT_CONSTRUCTOR)
85 }
86
87 #[inline]
88 #[must_use]
89 pub const fn has_consistent_templates(self) -> bool {
90 self.contains(Self::CONSISTENT_TEMPLATES)
91 }
92
93 #[inline]
94 #[must_use]
95 pub const fn is_user_defined(self) -> bool {
96 self.contains(Self::USER_DEFINED)
97 }
98
99 #[inline]
100 #[must_use]
101 pub const fn is_built_in(self) -> bool {
102 self.contains(Self::BUILTIN)
103 }
104
105 #[inline]
106 #[must_use]
107 pub const fn is_internal(self) -> bool {
108 self.contains(Self::INTERNAL)
109 }
110
111 #[inline]
112 #[must_use]
113 pub const fn is_populated(self) -> bool {
114 self.contains(Self::POPULATED)
115 }
116
117 #[inline]
118 #[must_use]
119 pub const fn is_readonly(self) -> bool {
120 self.contains(Self::READONLY)
121 }
122
123 #[inline]
124 #[must_use]
125 pub const fn is_writeonly(self) -> bool {
126 self.contains(Self::WRITEONLY)
127 }
128
129 #[inline]
130 #[must_use]
131 pub const fn is_enum_interface(self) -> bool {
132 self.contains(Self::ENUM_INTERFACE)
133 }
134
135 #[inline]
136 #[must_use]
137 pub const fn is_unchecked(self) -> bool {
138 self.contains(Self::UNCHECKED)
139 }
140
141 #[inline]
142 #[must_use]
143 pub const fn ignore_nullable_return(self) -> bool {
144 self.contains(Self::IGNORE_NULLABLE_RETURN)
145 }
146
147 #[inline]
148 #[must_use]
149 pub const fn ignore_falsable_return(self) -> bool {
150 self.contains(Self::IGNORE_FALSABLE_RETURN)
151 }
152
153 #[inline]
154 #[must_use]
155 pub const fn inherits_docs(self) -> bool {
156 self.contains(Self::INHERITS_DOCS)
157 }
158
159 #[inline]
160 #[must_use]
161 pub const fn forbids_named_arguments(self) -> bool {
162 self.contains(Self::NO_NAMED_ARGUMENTS)
163 }
164
165 #[inline]
166 #[must_use]
167 pub const fn has_throw(self) -> bool {
168 self.contains(Self::HAS_THROW)
169 }
170
171 #[inline]
172 #[must_use]
173 pub const fn is_backed_enum_case(self) -> bool {
174 self.contains(Self::BACKED_ENUM_CASE)
175 }
176
177 #[inline]
178 #[must_use]
179 pub const fn is_unit_enum_case(self) -> bool {
180 self.contains(Self::UNIT_ENUM_CASE)
181 }
182
183 #[inline]
184 #[must_use]
185 pub const fn is_by_reference(self) -> bool {
186 self.contains(Self::BY_REFERENCE)
187 }
188
189 #[inline]
190 #[must_use]
191 pub const fn is_variadic(self) -> bool {
192 self.contains(Self::VARIADIC)
193 }
194
195 #[inline]
196 #[must_use]
197 pub const fn is_promoted_property(self) -> bool {
198 self.contains(Self::PROMOTED_PROPERTY)
199 }
200
201 #[inline]
202 #[must_use]
203 pub const fn has_default(self) -> bool {
204 self.contains(Self::HAS_DEFAULT)
205 }
206
207 #[inline]
208 #[must_use]
209 pub const fn is_virtual_property(self) -> bool {
210 self.contains(Self::VIRTUAL_PROPERTY)
211 }
212
213 #[inline]
214 #[must_use]
215 pub const fn is_magic_property(self) -> bool {
216 self.contains(Self::MAGIC_PROPERTY)
217 }
218
219 #[inline]
220 #[must_use]
221 pub const fn is_magic_method(self) -> bool {
222 self.contains(Self::MAGIC_METHOD)
223 }
224
225 #[inline]
226 #[must_use]
227 pub const fn is_asymmetric_property(self) -> bool {
228 self.contains(Self::ASYMMETRIC_PROPERTY)
229 }
230
231 #[inline]
232 #[must_use]
233 pub const fn is_static(self) -> bool {
234 self.contains(Self::STATIC)
235 }
236}