1#[allow(unused_macros)]
21macro_rules! define_data_value {
22 (
23 v: $Value:ident, t: $Type:ident, r: $Raw:ident,
24 size: $b:literal, feature: $feature:literal,
25
26 copy:
27 $( $C_doc:literal, $C_name:ident, $C_type:ty,
28 [def:$C_def:stmt]
29 )* ;
30 copy@dep:
31 $( $C_doc_dep:literal, $C_name_dep:ident, $C_type_dep:ty,
32 $C_dep1_dep:literal, $C_dep2_dep:literal,
33 [def:$C_def_dep:stmt]
34 )* ;
35 copy@ptr:
36 $( $C_doc_ptr:literal, $C_name_ptr:ident, $C_type_ptr:ty,
37 $C_ptr_ptr:meta,
38 [def:$C_def_ptr:stmt]
39 )* ;
40 copy@ptrdep:
41 $( $C_doc_ptrdep:literal, $C_name_ptrdep:ident, $C_type_ptrdep:ty,
42 $C_ptr_ptrdep:meta, $C_dep1_ptrdep:literal, $C_dep2_ptrdep:literal,
43 [def:$C_def_ptrdep:stmt]
44 )* ;
45
46 noncopy:
47 $( $N_doc:literal, $N_name:ident, $N_type:ty,
48 [def:$N_def:stmt]
49 )* ;
50 noncopy@dep:
51 $( $N_doc_dep:literal, $N_name_dep:ident, $N_type_dep:ty,
52 $N_dep1_dep:literal, $N_dep2_dep:literal,
53 [def:$N_def_dep:stmt]
54 )* ;
55 noncopy@ptr:
56 $( $N_doc_ptr:literal, $N_name_ptr:ident, $N_type_ptr:ty,
57 $N_ptr_ptr:meta, $N_dep1_ptr:literal, $N_dep2_ptr:literal,
58 [def:$N_def_ptr:stmt]
59 )* ;
60 noncopy@ptrdep:
61 $( $N_doc_ptrdep:literal, $N_name_ptrdep:ident, $N_type_ptrdep:ty,
62 $N_ptr_ptrdep:meta, $N_dep1_ptrdep:literal, $N_dep2_ptrdep:literal,
63 [def:$N_def_ptrdep:stmt]
64 )* ;
65 ) => { $crate::paste! {
66 #[doc = $b "-bit data *value*, restricted to `Copy` variants, with extra `V`." ]
69 #[doc = "- [" [<$Type $b Copy With>] "]" ]
72 #[doc = "- [" [<$Value $b With>] "][" [<$Value $b With>] "] -Copy" ]
73 #[doc = "- [" [<$Value $b Copy>] "][" [<$Value $b Copy>] "] -With" ]
74 #[doc = "- [" [<$Value $b>] "][" [<$Value $b>] "] -Copy -With" ]
75 #[derive(Clone, Copy, Debug, PartialEq)]
76 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
77 pub enum [<$Value $b Copy With>]<V: DataValue> {
78 None,
80 Extra(V),
82
83 $( #[doc = $C_doc]
85 $C_name($C_type),
86 )*
87
88 $( #[cfg($C_ptr_ptr)]
90 #[doc = $C_doc_ptr]
91 $C_name_ptr($C_type_ptr),
92 )*
93
94 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
96 #[cfg_attr(feature = "nightly_doc",
97 doc(cfg(all(feature = $C_dep1_dep,
98 feature = $C_dep2_dep))))]
99 #[doc = $C_doc_dep]
100 $C_name_dep($C_type_dep),
101 )*
102
103 $( #[cfg(all($C_ptr_ptrdep,
105 feature = $C_dep1_ptrdep,
106 feature = $C_dep2_ptrdep))]
107 #[cfg_attr(feature = "nightly_doc",
108 doc(cfg(all(feature = $C_dep1_ptrdep,
109 feature = $C_dep2_ptrdep))))]
110 #[doc = $C_doc_ptrdep]
111 $C_name_ptrdep($C_type_ptrdep),
112 )*
113 }
114
115 #[doc = $b "-bit data *value*, restricted to `Copy` variants." ]
117 #[doc = "- [" [<$Type $b Copy>] "]" ]
120 #[doc = "- [" [<$Value $b>] "][" [<$Value $b>] "] -Copy" ]
121 #[doc = "- [" [<$Value $b Copy With>] "][" [<$Value $b Copy With>] "] +With" ]
122 #[doc = "- [" [<$Value $b With>] "][" [<$Value $b With>] "] -Copy +With" ]
123 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
124 pub type [<$Value $b Copy>] = [< $Value $b Copy With>]<$crate::NoData>;
125
126 $crate::impl_data_value![
128 v: [< $Value $b Copy With >], DataValue,
129 t: [< $Type $b Copy With >], DataType,
130 all_are_copy: true,
131
132 copy:
133 $( $C_name, $C_type
134 ),* ;
135 copy@dep:
136 $( $C_name_dep, $C_type_dep,
137 $C_dep1_dep, $C_dep2_dep
138 ),* ;
139 copy@ptr:
140 $( $C_name_ptr, $C_type_ptr,
141 $C_ptr_ptr
142 ),* ;
143 copy@ptrdep:
144 $( $C_name_ptrdep, $C_type_ptrdep,
145 $C_ptr_ptrdep,
146 $C_dep1_ptrdep, $C_dep2_ptrdep
147 ),* ;
148
149 noncopy: ;
150 noncopy@dep: ;
151 noncopy@ptr: ;
152 noncopy@ptrdep: ;
153 ];
154 impl<V: DataValueCopy> DataValueCopy for [< $Value $b Copy With >]<V> { }
155
156 #[doc = $b "-bit data *value*, with extra `V`." ]
159 #[doc = "- [" [<$Type $b With>] "]" ]
162 #[doc = "- [" [<$Value $b Copy With>] "][" [<$Value $b Copy With>] "] +Copy" ]
163 #[doc = "- [" [<$Value $b>] "][" [<$Value $b>] "] -Width" ]
164 #[doc = "- [" [<$Value $b Copy>] "][" [<$Value $b Copy>] "] +Copy -Width" ]
165 #[derive(Clone, Debug, PartialEq)]
166 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
167 pub enum [<$Value $b With>]<V: DataValue> {
168 None,
170 Extra(V),
172
173 $( #[doc = $C_doc]
175 $C_name($C_type),
176 )*
177 $(
178 #[doc = $N_doc]
179 $N_name($N_type),
180 )*
181
182 $( #[cfg($C_ptr_ptr)]
184 #[doc = $C_doc_ptr]
185 $C_name_ptr($C_type_ptr),
186 )*
187 $(
188 #[cfg($N_ptr_ptr)]
189 #[doc = $N_doc_ptr]
190 $N_name_ptr($N_type_ptr),
191 )*
192
193 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
195 #[cfg_attr(feature = "nightly_doc",
196 doc(cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))))]
197 #[doc = $C_doc_dep]
198 $C_name_dep($C_type_dep),
199 )*
200 $(
201 #[cfg(all(feature = $N_dep1_dep, feature = $N_dep2_dep))]
202 #[cfg_attr(feature = "nightly_doc",
203 doc(cfg(all(feature = $N_dep1_dep, feature = $N_dep2_dep))))]
204 #[doc = $N_doc_dep]
205 $N_name_dep($N_type_dep),
206 )*
207
208 $( #[cfg(all($C_ptr_ptrdep,
210 feature = $C_dep1_ptrdep,
211 feature = $C_dep2_ptrdep))]
212 #[cfg_attr(feature = "nightly_doc",
213 doc(cfg(all(feature = $C_dep1_ptrdep,
214 feature = $C_dep2_ptrdep))))]
215 #[doc = $C_doc_ptrdep]
216 $C_name_ptrdep($C_type_ptrdep),
217 )*
218 $(
219 #[cfg(all($N_ptr_ptrdep,
220 feature = $N_dep1_ptrdep,
221 feature = $N_dep2_ptrdep))]
222 #[cfg_attr(feature = "nightly_doc",
223 doc(cfg(all(feature = $N_dep1_ptrdep,
224 feature = $N_dep2_ptrdep))))]
225 #[doc = $N_doc_ptrdep]
226 $N_name_ptrdep($N_type_ptrdep),
227 )*
228 }
229
230 #[doc = $b "-bit data *value*." ]
232 #[doc = "- [" [<$Type $b>] "]" ]
235 #[doc = "- [" [<$Value $b Copy>] "][" [<$Value $b Copy>] "] +Copy" ]
236 #[doc = "- [" [<$Value $b With>] "][" [<$Value $b With>] "] +With" ]
237 #[doc = "- [" [<$Value $b Copy With>] "][" [<$Value $b Copy With>] "] +Copy +With" ]
238 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
239 pub type [<$Value $b>] = [< $Value $b With>]<$crate::NoData>;
240
241 $crate::impl_data_value![
243 v: [< $Value $b With >], DataValue,
244 t: [< $Type $b With >], DataType,
245 all_are_copy: false,
246
247 copy:
248 $( $C_name, $C_type
249 ),* ;
250 copy@dep:
251 $( $C_name_dep, $C_type_dep,
252 $C_dep1_dep, $C_dep2_dep
253 ),* ;
254 copy@ptr:
255 $( $C_name_ptr, $C_type_ptr,
256 $C_ptr_ptr
257 ),* ;
258 copy@ptrdep:
259 $( $C_name_ptrdep, $C_type_ptrdep,
260 $C_ptr_ptrdep,
261 $C_dep1_ptrdep, $C_dep2_ptrdep
262 ),* ;
263
264 noncopy:
265 $( $N_name, $N_type
266 ),* ;
267 noncopy@dep:
268 $( $N_name_dep, $N_type_dep,
269 $N_dep1_dep, $N_dep2_dep
270 ),* ;
271 noncopy@ptr:
272 $( $N_name_ptr, $N_type_ptr,
273 $N_ptr_ptr
274 ),* ;
275 noncopy@ptrdep:
276 $( $N_name_ptrdep, $N_type_ptrdep,
277 $N_ptr_ptrdep,
278 $N_dep1_ptrdep, $N_dep2_ptrdep
279 ),* ;
280 ];
281
282 $( impl<V: DataValueCopy> TryFrom<[<$Value $b Copy With>]<V>> for $C_type {
286 type Error = ();
287 fn try_from(v: [<$Value $b Copy With>]<V>) -> Result<Self, Self::Error> {
288 match v {
289 [<$Value $b Copy With>]::$C_name(v) => Ok(v),
290 _ => Err(()),
291 }
292 }
293 }
294 )*
295 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep ))]
297 impl<V: DataValue> TryFrom<[<$Value $b With>]<V>> for $C_type_dep {
298 type Error = ();
299 fn try_from(v: [<$Value $b With>]<V>) -> Result<Self, Self::Error> {
300 match v {
301 [<$Value $b With>]::$C_name_dep(v) => Ok(v),
302 _ => Err(()),
303 }
304 }
305 }
306 )*
307 $( impl<V: DataValue> TryFrom<[<$Value $b With>]<V>> for $N_type {
309 type Error = ();
310 fn try_from(v: [<$Value $b With>]<V>) -> Result<Self, Self::Error> {
311 match v {
312 [<$Value $b With>]::$N_name(v) => Ok(v),
313 _ => Err(()),
314 }
315 }
316 }
317 )*
318 $( #[cfg(all(feature = $N_dep1_dep, feature = $N_dep2_dep ))]
320 impl<V: DataValue> TryFrom<[<$Value $b With>]<V>> for $N_type_dep {
321 type Error = ();
322 fn try_from(v: [<$Value $b With>]<V>) -> Result<Self, Self::Error> {
323 match c {
324 [<$Value $b With>]::$N_name_dep(v) => Ok(v),
325 _ => Err(()),
326 }
327 }
328 }
329 )*
330
331 $( impl<V: DataValueCopy> From<$C_type> for [<$Value $b Copy With>]<V> {
335 fn from(v: $C_type) -> Self {
336 [<$Value $b Copy With>]::$C_name(v)
337 }
338 }
339 )*
340 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep ))]
342 impl<V: DataValueCopy> From<$C_type_dep> for [<$Value $b Copy With>]<V> {
343 fn from(v: $C_type_dep) -> Self {
344 [<$Value $b Copy With>]::$C_name_dep(v)
345 }
346 }
347 )*
348 $( impl<V: DataValue> From<$N_type> for [<$Value $b With>]<V> {
350 fn from(v: $N_type) -> Self {
351 [<$Value $b With>]::$N_name(v)
352 }
353 }
354 )*
355 $( #[cfg(all(feature = $N_dep1_dep, feature = $N_dep2_dep ))]
357 impl<V: DataValue> From<$N_type_dep> for [<$Value $b With>]<V> {
358 fn from(v: $N_type_dep) -> Self {
359 [<$Value $b With>]::$N_name_dep(v)
360 }
361 }
362 )*
363
364 #[cfg(all(not(feature = "safe_data"), feature = "unsafe_layout"))]
366 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_layout")))]
367 impl<V: DataValueCopy> From<[<$Value $b Copy With>]<V>> for [<$Raw $b Copy>] {
368 fn from(cell: [<$Value $b Copy With>]<V>) -> Self {
369 match cell {
370 [<$Value $b Copy With>]::None => Self { None: () },
371 [<$Value $b Copy With>]::Extra(_) => Self { None: () }, $( [<$Value $b Copy With>]::$C_name(v) => Self { $C_name: v },
375 )*
376
377 $( #[cfg($C_ptr_ptr)]
379 [<$Value $b Copy With>]::$C_name_ptr(v) => Self { $C_name_ptr: v },
380 )*
381
382 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
384 [<$Value $b Copy With>]::$C_name_dep(v) => Self { $C_name_dep: v },
385 )*
386 }
387 }
388 }
389 }};
390}
391#[allow(unused_imports)]
392pub(crate) use define_data_value;
393#[allow(unused_macros)]
395macro_rules! define_data_type {
396 (
397 v: $Value:ident, t: $Type:ident, r: $Raw:ident,
398 size: $b:literal, feature: $feature:literal,
399
400 copy:
401 $( $C_doc:literal, $C_name:ident, $C_type:ty,
402 [def:$C_def:stmt]
403 )* ;
404 copy@dep:
405 $( $C_doc_dep:literal, $C_name_dep:ident, $C_type_dep:ty,
406 $C_dep1_dep:literal, $C_dep2_dep:literal,
407 [def:$C_def_dep:stmt]
408 )* ;
409 copy@ptr:
410 $( $C_doc_ptr:literal, $C_name_ptr:ident, $C_type_ptr:ty,
411 $C_ptr_ptr:meta,
412 [def:$C_def_ptr:stmt]
413 )* ;
414 copy@ptrdep:
415 $( $C_doc_ptrdep:literal, $C_name_ptrdep:ident, $C_type_ptrdep:ty,
416 $C_ptr_ptrdep:meta, $C_dep1_ptrdep:literal, $C_dep2_ptrdep:literal,
417 [def:$C_def_ptrdep:stmt]
418 )* ;
419
420 noncopy:
421 $( $N_doc:literal, $N_name:ident, $N_type:ty,
422 [def:$N_def:stmt]
423 )* ;
424 noncopy@dep:
425 $( $N_doc_dep:literal, $N_name_dep:ident, $N_type_dep:ty,
426 $N_dep1_dep:literal, $N_dep2_dep:literal,
427 [def:$N_def_dep:stmt]
428 )* ;
429 noncopy@ptr:
430 $( $N_doc_ptr:literal, $N_name_ptr:ident, $N_type_ptr:ty,
431 $N_ptr_ptr:meta, $N_dep1_ptr:literal, $N_dep2_ptr:literal,
432 [def:$N_def_ptr:stmt]
433 )* ;
434 noncopy@ptrdep:
435 $( $N_doc_ptrdep:literal, $N_name_ptrdep:ident, $N_type_ptrdep:ty,
436 $N_ptr_ptrdep:meta, $N_dep1_ptrdep:literal, $N_dep2_ptrdep:literal,
437 [def:$N_def_ptrdep:stmt]
438 )* ;
439 ) => { $crate::paste! {
440 #[doc = $b "-bit data *type*, restricted to `Copy` variants, with extra `T`." ]
443 #[doc = "- [" [<$Value $b Copy With>] "]" ]
446 #[doc = "- [" [<$Type $b With>] "][" [<$Type $b With>] "] -Copy" ]
447 #[doc = "- [" [<$Type $b Copy>] "][" [<$Type $b Copy>] "] -With" ]
448 #[doc = "- [" [<$Type $b>] "][" [<$Type $b>] "] -Copy -With" ]
449 #[derive(Clone, Copy, Debug, PartialEq)]
450 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
451 pub enum [< $Type $b Copy With >]<T: DataType> {
452 None,
454 Extra(T),
456
457 $( #[doc = $C_doc ]
459 $C_name,
460 )*
461
462 $( #[cfg($C_ptr_ptr)]
464 #[doc = $C_doc_ptr]
465 $C_name_ptr,
466 )*
467
468 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
470 #[cfg_attr(feature = "nightly_doc",
471 doc(cfg(all(feature = $C_dep1_dep,
472 feature = $C_dep2_dep))))]
473 #[doc = $C_doc_dep]
474 $C_name_dep,
475 )*
476
477 $( #[cfg(all($C_ptr_ptrdep,
479 feature = $C_dep1_ptrdep,
480 feature = $C_dep2_ptrdep))]
481 #[cfg_attr(feature = "nightly_doc",
482 doc(cfg(all(feature = $C_dep1_ptrdep,
483 feature = $C_dep2_ptrdep))))]
484 #[doc = $C_doc_ptrdep]
485 $C_name_ptrdep,
486 )*
487 }
488
489 #[doc = $b "-bit data *type*, restricted to `Copy` variants." ]
491 #[doc = "- [" [<$Value $b Copy>] "]" ]
494 #[doc = "- [" [<$Type $b>] "][" [<$Type $b>] "] -Copy" ]
495 #[doc = "- [" [<$Type $b Copy With>] "][" [<$Type $b Copy With>] "] +With" ]
496 #[doc = "- [" [<$Type $b With>] "][" [<$Type $b With>] "] -Copy +With" ]
497 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
498 pub type [<$Type $b Copy>] = [< $Type $b Copy With>]<$crate::NoData>;
499
500 $crate::impl_data_type![
502 v: [< $Value $b Copy With >], DataValue,
503 t: [< $Type $b Copy With >], DataType,
504 all_are_copy: true,
505
506 copy:
507 $( $C_name, $C_type,
508 [def:$C_def]
509 )* ;
510 copy@dep:
511 $( $C_name_dep, $C_type_dep,
512 $C_dep1_dep, $C_dep2_dep,
513 [def:$C_def_dep]
514 )* ;
515 copy@ptr:
516 $( $C_name_ptr, $C_type_ptr,
517 $C_ptr_ptr,
518 [def:$C_def_ptr]
519 )* ;
520 copy@ptrdep:
521 $( $C_name_ptrdep, $C_type_ptrdep,
522 $C_ptr_ptrdep,
523 $C_dep1_ptrdep, $C_dep2_ptrdep,
524 [def:$C_def_ptrdep]
525 )* ;
526
527 noncopy: ;
528 noncopy@dep: ;
529 noncopy@ptr: ;
530 noncopy@ptrdep: ;
531 ];
532 impl<T: DataTypeCopy> DataTypeCopy for [< $Type $b Copy With >]<T>
533 where T::Value: DataValueCopy {}
534
535 #[doc = $b "-bit data *type*, with extra `T`." ]
538 #[doc = "- [" [<$Value $b With>] "]" ]
541 #[doc = "- [" [<$Type $b Copy With>] "][" [<$Type $b Copy With>] "] +Copy" ]
542 #[doc = "- [" [<$Type $b>] "][" [<$Type $b>] "] -With" ]
543 #[doc = "- [" [<$Type $b Copy>] "][" [<$Type $b Copy>] "] +Copy -With" ]
544 #[derive(Clone, Copy, Debug, PartialEq)]
545 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
546 pub enum [< $Type $b With >]<T: DataType> {
547 None,
549 Extra(T),
551
552 $( #[doc = $C_doc ]
554 $C_name,
555 )*
556 $(
557 #[doc = $N_doc ]
558 $N_name,
559 )*
560
561 $( #[cfg($C_ptr_ptr)]
563 #[doc = $C_doc_ptr]
564 $C_name_ptr,
565 )*
566 $(
567 #[cfg($N_ptr_ptr)]
568 #[doc = $N_doc_ptr]
569 $N_name_ptr,
570 )*
571
572 $( #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
574 #[cfg_attr(feature = "nightly_doc",
575 doc(cfg(all(feature = $C_dep1_dep,
576 feature = $C_dep2_dep))))]
577 #[doc = $C_doc_dep]
578 $C_name_dep,
579 )*
580 $(
581 #[cfg(all(feature = $N_dep1_dep, feature = $N_dep2_dep))]
582 #[cfg_attr(feature = "nightly_doc",
583 doc(cfg(all(feature = $N_dep1_dep,
584 feature = $N_dep2_dep))))]
585 #[doc = $N_doc_dep]
586 $N_name_dep,
587 )*
588 $( #[cfg(all($C_ptr_ptrdep,
590 feature = $C_dep1_ptrdep,
591 feature = $C_dep2_ptrdep))]
592 #[cfg_attr(feature = "nightly_doc",
593 doc(cfg(all(feature = $C_dep1_ptrdep,
594 feature = $C_dep2_ptrdep))))]
595 #[doc = $C_doc_ptrdep]
596 $C_name_ptrdep,
597 )*
598 $(
599 #[cfg(all($N_ptr_ptrdep,
600 feature = $N_dep1_ptrdep,
601 feature = $N_dep2_ptrdep))]
602 #[cfg_attr(feature = "nightly_doc",
603 doc(cfg(all(feature = $N_dep1_ptrdep,
604 feature = $N_dep2_ptrdep))))]
605 #[doc = $N_doc_ptrdep]
606 $N_name_ptrdep,
607 )*
608 }
609
610 #[doc = $b "-bit data *type*"]
612 #[doc = "- [" [<$Value $b>] "]" ]
615 #[doc = "- [" [<$Type $b Copy>] "][" [<$Type $b Copy>] "] +Copy" ]
616 #[doc = "- [" [<$Type $b With>] "][" [<$Type $b With>] "] +With" ]
617 #[doc = "- [" [<$Type $b Copy With>] "][" [<$Type $b Copy With>] "] +Copy +With" ]
618 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
619 pub type [<$Type $b>] = [< $Type $b With>]<$crate::NoData>;
620
621 $crate::impl_data_type![
623 v: [< $Value $b With >], DataValue,
624 t: [< $Type $b With >], DataType,
625 all_are_copy: false,
626
627 copy:
628 $( $C_name, $C_type,
629 [def:$C_def]
630 )* ;
631 copy@dep:
632 $( $C_name_dep, $C_type_dep,
633 $C_dep1_dep, $C_dep2_dep,
634 [def:$C_def_dep]
635 )* ;
636 copy@ptr:
637 $( $C_name_ptr, $C_type_ptr,
638 $C_ptr_ptr,
639 [def:$C_def_ptr]
640 )* ;
641 copy@ptrdep:
642 $( $C_name_ptrdep, $C_type_ptrdep,
643 $C_ptr_ptrdep,
644 $C_dep1_ptrdep, $C_dep2_ptrdep,
645 [def:$C_def_ptrdep]
646 )* ;
647
648 noncopy:
649 $($N_name, $N_type,
650 [def:$N_def]
651 )* ;
652 noncopy@dep:
653 $( $N_name_dep, $N_type_dep,
654 $N_dep1_dep, $N_dep2_dep,
655 [def:$N_def_dep]
656 )* ;
657 noncopy@ptr:
658 $( $N_name_ptr, $N_type_ptr,
659 $N_ptr_ptr,
660 [def:$N_def_ptr]
661 )* ;
662 noncopy@ptrdep:
663 $( $N_name_ptrdep, $N_type_ptrdep,
664 $N_ptr_ptrdep,
665 $N_dep1_ptrdep, $N_dep2_ptrdep,
666 [def:$N_def_ptrdep]
667 )* ;
668 ];
669 }};
670}
671#[allow(unused_imports)]
672pub(crate) use define_data_type;
673
674#[allow(unused_macros)]
688macro_rules! define_data_raw {
689 (
690 v: $Value:ident, t: $Type:ident, r: $Raw:ident,
691 size: $b:literal, feature: $feature:literal,
692
693 copy:
694 $( $C_doc:literal, $C_name:ident, $C_type:ty,
695 [def:$C_def:stmt]
696 )* ;
697 copy@dep:
698 $( $C_doc_dep:literal, $C_name_dep:ident, $C_type_dep:ty,
699 $C_dep1_dep:literal, $C_dep2_dep:literal,
700 [def:$C_def_dep:stmt]
701 )* ;
702 copy@ptr:
703 $( $C_doc_ptr:literal, $C_name_ptr:ident, $C_type_ptr:ty,
704 $C_ptr_ptr:meta,
705 [def:$C_def_ptr:stmt]
706 )* ;
707 copy@ptrdep:
708 $( $C_doc_ptrdep:literal, $C_name_ptrdep:ident, $C_type_ptrdep:ty,
709 $C_ptr_ptrdep:meta, $C_dep1_ptrdep:literal, $C_dep2_ptrdep:literal,
710 [def:$C_def_ptrdep:stmt]
711 )* ;
712
713 noncopy:
714 $( $N_doc:literal, $N_name:ident, $N_type:ty,
715 [def:$N_def:stmt]
716 )* ;
717 noncopy@dep:
718 $( $N_doc_dep:literal, $N_name_dep:ident, $N_type_dep:ty,
719 $N_dep1_dep:literal, $N_dep2_dep:literal,
720 [def:$N_def_dep:stmt]
721 )* ;
722 noncopy@ptr:
723 $( $N_doc_ptr:literal, $N_name_ptr:ident, $N_type_ptr:ty,
724 $N_ptr_ptr:meta, $N_dep1_ptr:literal, $N_dep2_ptr:literal,
725 [def:$N_def_ptr:stmt]
726 )* ;
727 noncopy@ptrdep:
728 $( $N_doc_ptrdep:literal, $N_name_ptrdep:ident, $N_type_ptrdep:ty,
729 $N_ptr_ptrdep:meta,
730 $N_dep1_ptrdep:literal, $N_dep2_ptrdep:literal,
731 [def:$N_def_ptrdep:stmt]
732 )* ;
733 ) => { $crate::paste!{
734 #[repr(C)]
737 #[doc = $b "-bit *raw* data, restricted to `Copy` variants."]
738 #[derive(Copy, Clone)]
739 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = $feature)))]
740 #[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "unsafe_layout")))]
741 #[cfg(all(not(feature = "safe_data"), feature = "unsafe_layout"))]
742 #[allow(non_snake_case, reason = "union fields named like enum variants")]
743 pub union [< $Raw $b Copy >] {
744 pub None: (),
746
747 $(
748 #[doc = $C_doc]
749 pub $C_name: $C_type,
750 )*
751
752 $( #[cfg($C_ptr_ptr)]
754 #[doc = $C_doc_ptr]
755 $C_name_ptr: $C_type_ptr,
756 )*
757
758 $(
760 #[cfg(all(feature = $C_dep1_dep, feature = $C_dep2_dep))]
761 #[cfg_attr(feature = "nightly_doc",
762 doc(cfg(all(feature = $C_dep1_dep,
763 feature = $C_dep2_dep))))]
764 #[doc = $C_doc_dep]
765 pub $C_name_dep: $C_type_dep,
766 )*
767
768 $( #[cfg(all($C_ptr_ptrdep,
770 feature = $C_dep1_ptrdep,
771 feature = $C_dep2_ptrdep))]
772 #[cfg_attr(feature = "nightly_doc",
773 doc(cfg(all(feature = $C_dep1_ptrdep,
774 feature = $C_dep2_ptrdep))))]
775 #[doc = $C_doc_ptrdep]
776 $C_name_ptrdep($C_type_ptrdep),
777 )*
778 }
779 #[cfg(all(not(feature = "safe_data"), feature = "unsafe_layout"))]
787 impl core::fmt::Debug for [<$Raw $b Copy>] {
788 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
789 write!(f, "{} {{...}}", stringify!{[< $Raw $b Copy>]})
790 }
791 }
792
793 #[cfg(all(not(feature = "safe_data"), feature = "unsafe_layout"))]
794 $crate::impl_data_raw![
795 r: [< $Raw $b Copy>],
796 ];
797 }};
798}
799#[allow(unused_imports)]
800pub(crate) use define_data_raw;