Typed

Trait Typed 

Source
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§

Source

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

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 &'static str

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for &'static Location<'static>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for &'static Path

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for EulerRot

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Cow<'static, str>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Cow<'static, Path>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for SocketAddr

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for bool

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for char

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for f32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for f64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for i8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for i16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for i32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for i64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for i128

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for isize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for u8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for u16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for u32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for u64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for u128

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for ()

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for usize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for BVec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for BVec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for BVec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for BVec3A

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for BVec4A

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Affine2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Affine3A

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Mat3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Mat2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Mat3A

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Mat4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Quat

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Vec3A

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DAffine2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DAffine3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DMat2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DMat3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DMat4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DQuat

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DVec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DVec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for DVec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I8Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I8Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I8Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I16Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I16Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I16Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for IVec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for IVec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for IVec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I64Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I64Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for I64Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U8Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U8Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U8Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U16Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U16Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U16Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for UVec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for UVec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for UVec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U64Vec2

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U64Vec3

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for U64Vec4

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for SmolStr

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonNilUuid

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Uuid

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for String

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for TypeId

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for RangeFull

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicBool

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicI8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicI16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicI32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicI64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicIsize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicU8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicU16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicU32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicU64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for AtomicUsize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Duration

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for OsString

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for PathBuf

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for Instant

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroI8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroI16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroI32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroI64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroI128

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroIsize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroU8

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroU16

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroU32

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroU64

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroU128

Source§

fn type_info() -> &'static TypeInfo

Source§

impl Typed for NonZeroUsize

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A,)

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B)

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<A: Reflect + MaybeTyped + TypePath + GetTypeRegistration, B: Reflect + MaybeTyped + TypePath + GetTypeRegistration, C: Reflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for (A, B, C)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

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)

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<K, V> Typed for BTreeMap<K, V>
where K: FromReflect + MaybeTyped + TypePath + GetTypeRegistration + Eq + Ord, V: FromReflect + MaybeTyped + TypePath + GetTypeRegistration,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<K, V, S> Typed for HashMap<K, V, S>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<K, V, S> Typed for HashMap<K, V, S>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Bound<T>
where Bound<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Option<T>
where Option<T>: Any + Send + Sync, T: TypePath + FromReflect + MaybeTyped + RegisterForReflection,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for BinaryHeap<T>
where BinaryHeap<T>: Any + Send + Sync, T: TypePath + Clone,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for BTreeSet<T>
where BTreeSet<T>: Any + Send + Sync, T: TypePath + Ord + Eq + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Arc<T>
where Arc<T>: Any + Send + Sync, T: TypePath + Send + Sync + ?Sized,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Saturating<T>
where Saturating<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Wrapping<T>
where Wrapping<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for Range<T>
where Range<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for RangeFrom<T>
where RangeFrom<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for RangeInclusive<T>
where RangeInclusive<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for RangeTo<T>
where RangeTo<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T> Typed for RangeToInclusive<T>
where RangeToInclusive<T>: Any + Send + Sync, T: TypePath + Clone + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

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,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T: SmallArray + TypePath + Send + Sync + 'static> Typed for SmallVec<T>
where T::Item: FromReflect + MaybeTyped + TypePath,

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T: FromReflect + MaybeTyped + Clone + TypePath + GetTypeRegistration> Typed for Cow<'static, [T]>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T: FromReflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for VecDeque<T>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T: FromReflect + MaybeTyped + TypePath + GetTypeRegistration> Typed for Vec<T>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<T: Reflect + MaybeTyped + TypePath + GetTypeRegistration, const N: usize> Typed for [T; N]

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<V, S> Typed for HashSet<V, S>

Source§

fn type_info() -> &'static TypeInfo

Source§

impl<V, S> Typed for HashSet<V, S>

Source§

fn type_info() -> &'static TypeInfo

Implementors§

Source§

impl Typed for dyn Reflect