Trait static_reflect::StaticReflect[][src]

pub unsafe trait StaticReflect {
    const TYPE_INFO: TypeInfo<'static>;
}
Expand description

The trait for types whose information can be accessed via static reflection.

In order to proper access any fields, the representation must be C-compatible. Otherwise, transmutes and pointer-arithmetic are pointless because they are already undefined behavior.

Safety

Incorrect implementation of this trait is considered undefined behavior. All the static type information must be correct at runtime.

For example, if this type gives field information via FieldReflect, then the field information must match the representation at runtime.

The advantage of this is that other crates can rely on the representation being stable (for example, JIT compilers can use it).

The type must be #[repr(C)] or have some other form of FFI safety.

Associated Constants

The static information about the type’s representation

Implementations on Foreign Types

Support StaticReflect for ManuallyDrop by just representing the inner type

A pointer

NOTE: The pointed-to value can be anything, even if it doesn’t implement StaticReflect.

This is fine since the static reflection system doesn’t maintain information about pointers (to avoid cycles).

An immutable pointer

The static reflection system makes no distinction between mutable and immutable pointers.

We have the representation as our internals, except for the fact we might be null

Implementors