Skip to main content

Typed

Trait Typed 

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§

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§

§

impl Typed for &'static str

§

fn type_info() -> &'static TypeInfo

§

impl Typed for &'static Location<'static>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for Cow<'static, str>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for SocketAddr

§

fn type_info() -> &'static TypeInfo

§

impl Typed for bool

§

fn type_info() -> &'static TypeInfo

§

impl Typed for char

§

fn type_info() -> &'static TypeInfo

§

impl Typed for f32

§

fn type_info() -> &'static TypeInfo

§

impl Typed for f64

§

fn type_info() -> &'static TypeInfo

§

impl Typed for i8

§

fn type_info() -> &'static TypeInfo

§

impl Typed for i16

§

fn type_info() -> &'static TypeInfo

§

impl Typed for i32

§

fn type_info() -> &'static TypeInfo

§

impl Typed for i64

§

fn type_info() -> &'static TypeInfo

§

impl Typed for i128

§

fn type_info() -> &'static TypeInfo

§

impl Typed for isize

§

fn type_info() -> &'static TypeInfo

§

impl Typed for u8

§

fn type_info() -> &'static TypeInfo

§

impl Typed for u16

§

fn type_info() -> &'static TypeInfo

§

impl Typed for u32

§

fn type_info() -> &'static TypeInfo

§

impl Typed for u64

§

fn type_info() -> &'static TypeInfo

§

impl Typed for u128

§

fn type_info() -> &'static TypeInfo

§

impl Typed for ()

§

fn type_info() -> &'static TypeInfo

§

impl Typed for usize

§

fn type_info() -> &'static TypeInfo

§

impl Typed for String

§

fn type_info() -> &'static TypeInfo

§

impl Typed for TypeId

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<i8>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<i16>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<i32>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<i64>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<i128>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<isize>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<u8>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<u16>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<u32>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<u64>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<u128>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for NonZero<usize>

§

fn type_info() -> &'static TypeInfo

§

impl Typed for RangeFull

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicBool

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicI8

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicI16

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicI32

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicI64

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicIsize

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicU8

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicU16

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicU32

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicU64

§

fn type_info() -> &'static TypeInfo

§

impl Typed for AtomicUsize

§

fn type_info() -> &'static TypeInfo

§

impl Typed for Duration

§

fn type_info() -> &'static TypeInfo

§

impl Typed for CuDuration

§

fn type_info() -> &'static TypeInfo

§

impl Typed for CuTimeRange

§

fn type_info() -> &'static TypeInfo

§

impl Typed for Instant

§

fn type_info() -> &'static TypeInfo

§

impl Typed for OptionCuTime

§

fn type_info() -> &'static TypeInfo

§

impl Typed for PartialCuTimeRange

§

fn type_info() -> &'static TypeInfo

§

impl Typed for Tov

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E> Typed for (A, B, C, D, E)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F> Typed for (A, B, C, D, E, F)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G> Typed for (A, B, C, D, E, F, G)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G, H> Typed for (A, B, C, D, E, F, G, H)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G, H, I> Typed for (A, B, C, D, E, F, G, H, I)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G, H, I, J> Typed for (A, B, C, D, E, F, G, H, I, J)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G, H, I, J, K> Typed for (A, B, C, D, E, F, G, H, I, J, K)
where 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,

§

fn type_info() -> &'static TypeInfo

§

impl<A, B, C, D, E, F, G, H, I, J, K, L> Typed for (A, B, C, D, E, F, G, H, I, J, K, L)
where 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,

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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,

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

§

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

§

fn type_info() -> &'static TypeInfo

Implementors§

§

impl Typed for dyn Reflect

Source§

impl<I> Typed for CuSimSinkTask<I>
where CuSimSinkTask<I>: Any + Send + Sync,

Source§

impl<T> Typed for CuSimSrcTask<T>
where CuSimSrcTask<T>: Any + Send + Sync,

Source§

impl<T, O> Typed for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

impl<T, const N: usize> Typed for CuArray<T, N>
where CuArray<T, N>: Any + Send + Sync, T: TypePath + Clone,