abi_stable/
reflection.rs

1//! Types and submodules for doing runtime reflection.
2
3#[cfg(all(test, not(feature = "only_new_tests")))]
4pub mod tests {
5    pub mod derive_reflection;
6}
7
8/// Implementation details of the sabi_extract tool.
9///
10/// This is here so that its tests run among other abi_stable tests.
11#[doc(hidden)]
12pub mod export_module;
13
14/// Whether this is a module whose definition can be reflected on at runtime,
15///
16/// Module reflection only allows accessing public fields.
17#[repr(u8)]
18#[derive(Debug, Copy, Clone, PartialEq, Eq, StableAbi)]
19pub enum ModReflMode {
20    /// For modules that are reflected on at runtime.
21    ///
22    /// This is the default for all types.
23    Module,
24    /// For types whose layout can't be iterated over.
25    ///
26    /// If one uses `#[sabi(module_reflection(Opaque))]`
27    Opaque,
28    /// Delegates the layout to some other type,this is generally for references.
29    DelegateDeref {
30        /// To which layout in `TypeLayout.shared_vars.type_layouts` this delegates to.
31        layout_index: u8,
32    },
33}
34
35impl Default for ModReflMode {
36    fn default() -> Self {
37        ModReflMode::Opaque
38    }
39}