pub trait Reflect: Any + Debug {
Show 19 methods fn type_name(&self) -> &'static str; fn fields_info(&self) -> Vec<FieldInfo<'_>>; fn into_any(self: Box<Self>) -> Box<dyn Any>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; fn as_reflect(&self) -> &dyn Reflect; fn as_reflect_mut(&mut self) -> &mut dyn Reflect; fn set(
        &mut self,
        value: Box<dyn Reflect>
    ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>; fn set_field(
        &mut self,
        field: &str,
        value: Box<dyn Reflect>
    ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>> { ... } fn fields(&self) -> Vec<&dyn Reflect> { ... } fn fields_mut(&mut self) -> Vec<&mut dyn Reflect> { ... } fn field(&self, _name: &str) -> Option<&dyn Reflect> { ... } fn field_mut(&mut self, _name: &str) -> Option<&mut dyn Reflect> { ... } fn as_array(&self) -> Option<&dyn ReflectArray> { ... } fn as_array_mut(&mut self) -> Option<&mut dyn ReflectArray> { ... } fn as_list(&self) -> Option<&dyn ReflectList> { ... } fn as_list_mut(&mut self) -> Option<&mut dyn ReflectList> { ... } fn as_inheritable_variable(&self) -> Option<&dyn ReflectInheritableVariable> { ... } fn as_inheritable_variable_mut(
        &mut self
    ) -> Option<&mut dyn ReflectInheritableVariable> { ... }
}
Expand description

Trait for runtime reflection

Derive macro is available.

Type attributes

  • #[reflect(hide_all)]: Hide all fields, just like Any
  • #[reflect(bounds)]: Add type boundary for Reflect impl

Field attributes

  • #[reflect(deref)]: Delegate the field access with deref
  • #[reflect(field = <method call>)]
  • #[reflect(field_mut = <method call>)]

Additional Trait Bounds

Reflect restricted to types that implement Debug trait, this is needed to convert the actual value to string. Display isn’t used here, because it can’t be derived and it is very tedious to implement it for every type that should support Reflect trait. It is a good compromise between development speed and the quality of the string output.

Required Methods§

Provided Methods§

Calls user method specified with #[reflect(setter = ..)] or falls back to Reflect::field_mut

Implementations§

Type-erased API

Sets a field by its path in the given entity. This method always uses Reflect::set_field which means, that it will always call custom property setters.

Trait Implementations§

Implementations on Foreign Types§

Implementors§