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