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.
If you need to use this trait as a generic bound along with other reflection traits,
for your convenience, consider using Reflectable
instead.
§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
Affine2: Any + Send + Sync,
Mat2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Vec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for Affine2where
Affine2: Any + Send + Sync,
Mat2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Vec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
glam
only.Source§impl Typed for Affine3Awhere
Affine3A: Any + Send + Sync,
Mat3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Vec3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for Affine3Awhere
Affine3A: Any + Send + Sync,
Mat3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Vec3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
glam
only.Source§impl Typed for DAffine2where
DAffine2: Any + Send + Sync,
DMat2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
DVec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for DAffine2where
DAffine2: Any + Send + Sync,
DMat2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
DVec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
glam
only.Source§impl Typed for DAffine3where
DAffine3: Any + Send + Sync,
DMat3: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
DVec3: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Available on crate feature glam
only.
impl Typed for DAffine3where
DAffine3: Any + Send + Sync,
DMat3: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
DVec3: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
glam
only.Source§impl Typed for AtomicBool
impl Typed for AtomicBool
Source§impl Typed for AtomicIsize
impl Typed for AtomicIsize
Source§impl Typed for AtomicUsize
impl Typed for AtomicUsize
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 + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration, K: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration, K: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K)
Source§impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration, K: Reflect + MaybeTyped + TypePath + GetTypeRegistration, L: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C, D, E, F, G, H, I, J, K, L)
impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration, D: Reflect + MaybeTyped + TypePath + GetTypeRegistration, E: Reflect + MaybeTyped + TypePath + GetTypeRegistration, F: Reflect + MaybeTyped + TypePath + GetTypeRegistration, G: Reflect + MaybeTyped + TypePath + GetTypeRegistration, H: Reflect + MaybeTyped + TypePath + GetTypeRegistration, I: Reflect + MaybeTyped + TypePath + GetTypeRegistration, J: Reflect + MaybeTyped + TypePath + GetTypeRegistration, K: Reflect + MaybeTyped + TypePath + GetTypeRegistration, L: Reflect + MaybeTyped + 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 + MaybeTyped + TypePath + GetTypeRegistration + Eq + Ord,
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
impl<K, V> Typed for BTreeMap<K, V>where
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Ord,
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
Source§impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
Source§impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,
S: TypePath + BuildHasher + Send + Sync,
impl<K, V, S> Typed for HashMap<K, V, S>where
K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Hash,
V: FromReflect + MaybeTyped + 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
Result<T, E>: Any + Send + Sync,
T: TypePath + FromReflect + MaybeTyped + RegisterForReflection,
E: TypePath + FromReflect + MaybeTyped + RegisterForReflection,
impl<T, E> Typed for Result<T, E>where
Result<T, E>: Any + Send + Sync,
T: TypePath + FromReflect + MaybeTyped + RegisterForReflection,
E: TypePath + FromReflect + MaybeTyped + RegisterForReflection,
Source§impl<T: SmallArray + TypePath + Send + Sync + 'static> Typed for SmallVec<T>
Available on crate feature smallvec
only.
impl<T: SmallArray + TypePath + Send + Sync + 'static> Typed for SmallVec<T>
smallvec
only.