Trait DynamicTypeInfo

Source
pub trait DynamicTypeInfo {
    // Required method
    fn type_ref(&self) -> &'static Type;

    // Provided methods
    fn variant(&self) -> Option<&str> { ... }
    fn field_any(&self, _id: FieldId<'_>) -> Option<&dyn Any> { ... }
    fn field_any_mut(&mut self, _id: FieldId<'_>) -> Option<&mut dyn Any> { ... }
}
Expand description

A type that has compile-time dynamic type information associated with it.

This trait is built to be compatible with being a trait object.

Required Methods§

Source

fn type_ref(&self) -> &'static Type

The dynamic statically known type information for this type.

Provided Methods§

Source

fn variant(&self) -> Option<&str>

Get the id of the currently active variant of this type, or None if the type is not an enum.

Source

fn field_any(&self, _id: FieldId<'_>) -> Option<&dyn Any>

Get a dynamic reference to the value of a field on this type with the given field id.

This method will return the current value of the given field if possible, or None if the given field does not exist or does not have a type matching the supplied type.

Source

fn field_any_mut(&mut self, _id: FieldId<'_>) -> Option<&mut dyn Any>

Get a mutable dynamic reference to the value of a field on this type with the given field id.

This method will return the current value of the given field if possible, or None if the given field does not exist or does not have a type matching the supplied type.

Implementations on Foreign Types§

Source§

impl DynamicTypeInfo for bool

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for char

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for f32

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for f64

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for i8

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for i16

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for i32

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for i64

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for isize

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for u8

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for u16

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for u32

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for u64

Source§

fn type_ref(&self) -> &'static Type

Source§

impl DynamicTypeInfo for usize

Source§

fn type_ref(&self) -> &'static Type

Implementors§