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§
Provided Methods§
Sourcefn variant(&self) -> Option<&str>
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
.
Sourcefn field_any(&self, _id: FieldId<'_>) -> Option<&dyn Any>
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.
Sourcefn field_any_mut(&mut self, _id: FieldId<'_>) -> Option<&mut dyn Any>
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.