pub trait Typed: Reflect + TypePath {
// Required method
fn type_info() -> &'static TypeInfo;
}
Expand description
A static accessor to compile-time type information.
This trait is automatically implemented by the #[derive(Reflect)]
macro
and allows type information to be processed without an instance of that type.
§Implementing
While it is recommended to leave implementing this trait to the #[derive(Reflect)]
macro,
it is possible to implement this trait manually. If a manual implementation is needed,
you must ensure that the information you provide is correct, otherwise various systems that
rely on this trait may fail in unexpected ways.
Implementors may have difficulty in generating a reference to TypeInfo
with a static
lifetime. Luckily, this crate comes with some utility structs, to make generating these
statics much simpler.
§Example
use bevy_reflect::Typed;
struct MyStruct {
foo: usize,
bar: (f32, f32)
}
impl Typed for MyStruct {
fn type_info() -> &'static TypeInfo {
static CELL: NonGenericTypeInfoCell = NonGenericTypeInfoCell::new();
CELL.get_or_set(|| {
let fields = [
NamedField::new::<usize >("foo"),
NamedField::new::<(f32, f32) >("bar"),
];
let info = StructInfo::new::<Self>(&fields);
TypeInfo::Struct(info)
})
}
}
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Typed for Affine2where
Self: Any + Send + Sync,
Mat2: FromReflect + TypePath + RegisterForReflection,
Vec2: FromReflect + TypePath + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for Affine2where
Self: Any + Send + Sync,
Mat2: FromReflect + TypePath + RegisterForReflection,
Vec2: FromReflect + TypePath + RegisterForReflection,
glam
only.Source§impl Typed for Affine3Awhere
Self: Any + Send + Sync,
Mat3A: FromReflect + TypePath + RegisterForReflection,
Vec3A: FromReflect + TypePath + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for Affine3Awhere
Self: Any + Send + Sync,
Mat3A: FromReflect + TypePath + RegisterForReflection,
Vec3A: FromReflect + TypePath + RegisterForReflection,
glam
only.Source§impl Typed for DAffine2where
Self: Any + Send + Sync,
DMat2: FromReflect + TypePath + RegisterForReflection,
DVec2: FromReflect + TypePath + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for DAffine2where
Self: Any + Send + Sync,
DMat2: FromReflect + TypePath + RegisterForReflection,
DVec2: FromReflect + TypePath + RegisterForReflection,
glam
only.Source§impl Typed for DAffine3where
Self: Any + Send + Sync,
DMat3: FromReflect + TypePath + RegisterForReflection,
DVec3: FromReflect + TypePath + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for DAffine3where
Self: Any + Send + Sync,
DMat3: FromReflect + TypePath + RegisterForReflection,
DVec3: FromReflect + TypePath + RegisterForReflection,
glam
only.Source§impl Typed for NonZeroI16
impl Typed for NonZeroI16
Source§impl Typed for NonZeroI32
impl Typed for NonZeroI32
Source§impl Typed for NonZeroI64
impl Typed for NonZeroI64
Source§impl Typed for NonZeroI128
impl Typed for NonZeroI128
Source§impl Typed for NonZeroIsize
impl Typed for NonZeroIsize
Source§impl Typed for NonZeroU16
impl Typed for NonZeroU16
Source§impl Typed for NonZeroU32
impl Typed for NonZeroU32
Source§impl Typed for NonZeroU64
impl Typed for NonZeroU64
Source§impl Typed for NonZeroU128
impl Typed for NonZeroU128
Source§impl Typed for NonZeroUsize
impl Typed for NonZeroUsize
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration> Typed for (A, B)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration> Typed for (A, B)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K)
Source§impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration, L: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K, L)
impl<A: Reflect + TypePath + GetTypeRegistration, B: Reflect + TypePath + GetTypeRegistration, C: Reflect + TypePath + GetTypeRegistration, D: Reflect + TypePath + GetTypeRegistration, E: Reflect + TypePath + GetTypeRegistration, F: Reflect + TypePath + GetTypeRegistration, G: Reflect + TypePath + GetTypeRegistration, H: Reflect + TypePath + GetTypeRegistration, I: Reflect + TypePath + GetTypeRegistration, J: Reflect + TypePath + GetTypeRegistration, K: Reflect + TypePath + GetTypeRegistration, L: Reflect + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K, L)
Source§impl<K, V> Typed for BTreeMap<K, V>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Ord,
V: FromReflect + TypePath + GetTypeRegistration,
impl<K, V> Typed for BTreeMap<K, V>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Ord,
V: FromReflect + TypePath + GetTypeRegistration,
Source§impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
Source§impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
Source§impl<T> Typed for BinaryHeap<T>
impl<T> Typed for BinaryHeap<T>
Source§impl<T> Typed for Saturating<T>
impl<T> Typed for Saturating<T>
Source§impl<T> Typed for RangeInclusive<T>
impl<T> Typed for RangeInclusive<T>
Source§impl<T> Typed for RangeToInclusive<T>
impl<T> Typed for RangeToInclusive<T>
Source§impl<T, E> Typed for Result<T, E>where
Self: Any + Send + Sync,
T: TypePath + FromReflect + RegisterForReflection,
E: TypePath + FromReflect + RegisterForReflection,
impl<T, E> Typed for Result<T, E>where
Self: Any + Send + Sync,
T: TypePath + FromReflect + RegisterForReflection,
E: TypePath + FromReflect + RegisterForReflection,
Source§impl<T: Array + TypePath + Send + Sync + 'static> Typed for SmallVec<T>
Available on crate feature smallvec
only.
impl<T: Array + TypePath + Send + Sync + 'static> Typed for SmallVec<T>
smallvec
only.