Trait bevy_reflect::Typed

source ·
pub trait Typed: Reflect {
    // 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>("MyStruct", &fields);
      TypeInfo::Struct(info)
    })
  }
}

Required Methods§

source

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Implementations on Foreign Types§

source§

impl Typed for char

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect, H: Reflect, I: Reflect, J: Reflect> Typed for (A, B, C, D, E, F, G, H, I, J)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for &'static Path

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for isize

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for i8

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for usize

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for Duration

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Hash + Eq + Clone + Send + Sync + 'static> Typed for HashSet<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroU8

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroI16

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect> Typed for (A, B, C, D, E)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for bool

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for Instant

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for u32

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect> Typed for (A,)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for u16

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for u128

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for u8

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroU128

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for i32

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for ()

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect> Typed for (A, B, C, D, E, F)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroUsize

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for OsString

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Send + Sync + 'static> Typed for RangeInclusive<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroI8

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: FromReflect> Typed for VecDeque<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl<K, V, S> Typed for HashMap<K, V, S>where K: FromReflect + Eq + Hash, V: FromReflect, S: BuildHasher + Send + Sync + 'static,

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for Cow<'static, str>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for PathBuf

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect, H: Reflect, I: Reflect, J: Reflect, K: Reflect> Typed for (A, B, C, D, E, F, G, H, I, J, K)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for i64

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect> Typed for (A, B)

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect> Typed for (A, B, C, D, E, F, G)

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Send + Sync + 'static> Typed for RangeToInclusive<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect> Typed for (A, B, C)

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: FromReflect> Typed for Option<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for u64

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for String

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Send + Sync + 'static> Typed for RangeFrom<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for f32

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Send + Sync + 'static> Typed for RangeTo<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroI64

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect, H: Reflect, I: Reflect, J: Reflect, K: Reflect, L: Reflect> Typed for (A, B, C, D, E, F, G, H, I, J, K, L)

source§

fn type_info() -> &'static TypeInfo

source§

impl<K, V, S> Typed for HashMap<K, V, S>where K: FromReflect + Eq + Hash, V: FromReflect, S: BuildHasher + Send + Sync + 'static,

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Send + Sync + 'static> Typed for Range<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect, H: Reflect> Typed for (A, B, C, D, E, F, G, H)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for i16

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroU16

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroI32

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect, E: Reflect, F: Reflect, G: Reflect, H: Reflect, I: Reflect> Typed for (A, B, C, D, E, F, G, H, I)

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroU32

source§

fn type_info() -> &'static TypeInfo

source§

impl<A: Reflect, B: Reflect, C: Reflect, D: Reflect> Typed for (A, B, C, D)

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Clone + Reflect + 'static, E: Clone + Reflect + 'static> Typed for Result<T, E>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for RangeFull

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroU64

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroIsize

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for NonZeroI128

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for i128

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: FromReflect> Typed for Vec<T>

source§

fn type_info() -> &'static TypeInfo

source§

impl Typed for f64

source§

fn type_info() -> &'static TypeInfo

source§

impl<T: Reflect, const N: usize> Typed for [T; N]

source§

fn type_info() -> &'static TypeInfo

Implementors§