1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/// Description of one struct, tuple, or enum-variant field.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct FieldInfo {
/// Declared field name, or its tuple index.
pub name: &'static str,
/// Canonical token representation of the declared Rust type.
pub type_name: &'static str,
/// Zero-based declaration index.
pub index: usize,
}
/// Description of one enum variant.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct VariantInfo {
/// Declared variant name.
pub name: &'static str,
/// Zero-based discriminant used by the default Serde representation.
pub index: usize,
/// Variant fields in declaration order.
pub fields: &'static [FieldInfo],
}
/// Static structural shape generated for a reflected type.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TypeShape {
/// A struct or tuple struct.
Struct(&'static [FieldInfo]),
/// An enum and all its variants.
Enum(&'static [VariantInfo]),
}
/// Compile-time structural reflection without runtime registration or allocation.
pub trait Reflect {
/// Fully qualified declared type name.
const TYPE_NAME: &'static str;
/// Static structural metadata.
const SHAPE: TypeShape;
}