facet_core/impls/internal/
ty.rs

1//! Facet implementation for Type and related types
2
3use crate::{Def, Facet, Shape, ShapeBuilder, Type, UserType, VTableDirect, vtable_direct};
4
5// Type - treat as opaque for now (complex nested enum with recursive references to Shape)
6unsafe impl Facet<'_> for Type {
7    const SHAPE: &'static Shape = &const {
8        const VTABLE: VTableDirect = vtable_direct!(Type => Debug,);
9
10        ShapeBuilder::for_sized::<Type>("Type")
11            .ty(Type::User(UserType::Opaque))
12            .def(Def::Scalar)
13            .vtable_direct(&VTABLE)
14            .copy()
15            .send()
16            .sync()
17            .build()
18    };
19}
20
21// PrimitiveType - treat as opaque
22unsafe impl Facet<'_> for crate::PrimitiveType {
23    const SHAPE: &'static Shape = &const {
24        const VTABLE: VTableDirect = vtable_direct!(crate::PrimitiveType => Debug,);
25
26        ShapeBuilder::for_sized::<crate::PrimitiveType>("PrimitiveType")
27            .ty(Type::User(UserType::Opaque))
28            .def(Def::Scalar)
29            .vtable_direct(&VTABLE)
30            .copy()
31            .send()
32            .sync()
33            .build()
34    };
35}
36
37// NumericType - treat as opaque
38unsafe impl Facet<'_> for crate::NumericType {
39    const SHAPE: &'static Shape = &const {
40        const VTABLE: VTableDirect = vtable_direct!(crate::NumericType => Debug,);
41
42        ShapeBuilder::for_sized::<crate::NumericType>("NumericType")
43            .ty(Type::User(UserType::Opaque))
44            .def(Def::Scalar)
45            .vtable_direct(&VTABLE)
46            .copy()
47            .send()
48            .sync()
49            .build()
50    };
51}
52
53// TextualType - treat as opaque
54unsafe impl Facet<'_> for crate::TextualType {
55    const SHAPE: &'static Shape = &const {
56        const VTABLE: VTableDirect = vtable_direct!(crate::TextualType => Debug,);
57
58        ShapeBuilder::for_sized::<crate::TextualType>("TextualType")
59            .ty(Type::User(UserType::Opaque))
60            .def(Def::Scalar)
61            .vtable_direct(&VTABLE)
62            .copy()
63            .send()
64            .sync()
65            .build()
66    };
67}
68
69// SequenceType - treat as opaque
70unsafe impl Facet<'_> for crate::SequenceType {
71    const SHAPE: &'static Shape = &const {
72        const VTABLE: VTableDirect = vtable_direct!(crate::SequenceType => Debug,);
73
74        ShapeBuilder::for_sized::<crate::SequenceType>("SequenceType")
75            .ty(Type::User(UserType::Opaque))
76            .def(Def::Scalar)
77            .vtable_direct(&VTABLE)
78            .copy()
79            .send()
80            .sync()
81            .build()
82    };
83}
84
85// ArrayType - treat as opaque
86unsafe impl Facet<'_> for crate::ArrayType {
87    const SHAPE: &'static Shape = &const {
88        const VTABLE: VTableDirect = vtable_direct!(crate::ArrayType => Debug,);
89
90        ShapeBuilder::for_sized::<crate::ArrayType>("ArrayType")
91            .ty(Type::User(UserType::Opaque))
92            .def(Def::Scalar)
93            .vtable_direct(&VTABLE)
94            .copy()
95            .send()
96            .sync()
97            .build()
98    };
99}
100
101// SliceType - treat as opaque
102unsafe impl Facet<'_> for crate::SliceType {
103    const SHAPE: &'static Shape = &const {
104        const VTABLE: VTableDirect = vtable_direct!(crate::SliceType => Debug,);
105
106        ShapeBuilder::for_sized::<crate::SliceType>("SliceType")
107            .ty(Type::User(UserType::Opaque))
108            .def(Def::Scalar)
109            .vtable_direct(&VTABLE)
110            .copy()
111            .send()
112            .sync()
113            .build()
114    };
115}
116
117// UserType - treat as opaque
118unsafe impl Facet<'_> for crate::UserType {
119    const SHAPE: &'static Shape = &const {
120        const VTABLE: VTableDirect = vtable_direct!(crate::UserType => Debug,);
121
122        ShapeBuilder::for_sized::<crate::UserType>("UserType")
123            .ty(Type::User(UserType::Opaque))
124            .def(Def::Scalar)
125            .vtable_direct(&VTABLE)
126            .copy()
127            .send()
128            .sync()
129            .build()
130    };
131}
132
133// StructType - treat as opaque
134unsafe impl Facet<'_> for crate::StructType {
135    const SHAPE: &'static Shape = &const {
136        const VTABLE: VTableDirect = vtable_direct!(crate::StructType => Debug,);
137
138        ShapeBuilder::for_sized::<crate::StructType>("StructType")
139            .ty(Type::User(UserType::Opaque))
140            .def(Def::Scalar)
141            .vtable_direct(&VTABLE)
142            .copy()
143            .send()
144            .sync()
145            .build()
146    };
147}
148
149// EnumType - treat as opaque
150unsafe impl Facet<'_> for crate::EnumType {
151    const SHAPE: &'static Shape = &const {
152        const VTABLE: VTableDirect = vtable_direct!(crate::EnumType => Debug,);
153
154        ShapeBuilder::for_sized::<crate::EnumType>("EnumType")
155            .ty(Type::User(UserType::Opaque))
156            .def(Def::Scalar)
157            .vtable_direct(&VTABLE)
158            .copy()
159            .send()
160            .sync()
161            .build()
162    };
163}
164
165// UnionType - treat as opaque
166unsafe impl Facet<'_> for crate::UnionType {
167    const SHAPE: &'static Shape = &const {
168        const VTABLE: VTableDirect = vtable_direct!(crate::UnionType => Debug,);
169
170        ShapeBuilder::for_sized::<crate::UnionType>("UnionType")
171            .ty(Type::User(UserType::Opaque))
172            .def(Def::Scalar)
173            .vtable_direct(&VTABLE)
174            .copy()
175            .send()
176            .sync()
177            .build()
178    };
179}
180
181// PointerType - treat as opaque
182unsafe impl Facet<'_> for crate::PointerType {
183    const SHAPE: &'static Shape = &const {
184        const VTABLE: VTableDirect = vtable_direct!(crate::PointerType => Debug,);
185
186        ShapeBuilder::for_sized::<crate::PointerType>("PointerType")
187            .ty(Type::User(UserType::Opaque))
188            .def(Def::Scalar)
189            .vtable_direct(&VTABLE)
190            .copy()
191            .send()
192            .sync()
193            .build()
194    };
195}
196
197// ValuePointerType - treat as opaque
198unsafe impl Facet<'_> for crate::ValuePointerType {
199    const SHAPE: &'static Shape = &const {
200        const VTABLE: VTableDirect = vtable_direct!(crate::ValuePointerType => Debug,);
201
202        ShapeBuilder::for_sized::<crate::ValuePointerType>("ValuePointerType")
203            .ty(Type::User(UserType::Opaque))
204            .def(Def::Scalar)
205            .vtable_direct(&VTABLE)
206            .copy()
207            .send()
208            .sync()
209            .build()
210    };
211}
212
213// FunctionPointerDef - treat as opaque
214unsafe impl Facet<'_> for crate::FunctionPointerDef {
215    const SHAPE: &'static Shape = &const {
216        const VTABLE: VTableDirect = vtable_direct!(crate::FunctionPointerDef => Debug,);
217
218        ShapeBuilder::for_sized::<crate::FunctionPointerDef>("FunctionPointerDef")
219            .ty(Type::User(UserType::Opaque))
220            .def(Def::Scalar)
221            .vtable_direct(&VTABLE)
222            .copy()
223            .send()
224            .sync()
225            .build()
226    };
227}
228
229// Repr - treat as opaque
230unsafe impl Facet<'_> for crate::Repr {
231    const SHAPE: &'static Shape = &const {
232        const VTABLE: VTableDirect = vtable_direct!(crate::Repr => Debug, Hash, PartialEq,);
233
234        ShapeBuilder::for_sized::<crate::Repr>("Repr")
235            .ty(Type::User(UserType::Opaque))
236            .def(Def::Scalar)
237            .vtable_direct(&VTABLE)
238            .copy()
239            .send()
240            .sync()
241            .eq()
242            .build()
243    };
244}
245
246// BaseRepr - treat as opaque
247unsafe impl Facet<'_> for crate::BaseRepr {
248    const SHAPE: &'static Shape = &const {
249        const VTABLE: VTableDirect = vtable_direct!(crate::BaseRepr => Debug, Hash, PartialEq,);
250
251        ShapeBuilder::for_sized::<crate::BaseRepr>("BaseRepr")
252            .ty(Type::User(UserType::Opaque))
253            .def(Def::Scalar)
254            .vtable_direct(&VTABLE)
255            .copy()
256            .send()
257            .sync()
258            .eq()
259            .build()
260    };
261}