pub enum TypeInfo {
Struct(StructInfo),
TupleStruct(TupleStructInfo),
Tuple(TupleInfo),
List(ListInfo),
Array(ArrayInfo),
Map(MapInfo),
Enum(EnumInfo),
Value(ValueInfo),
}
Expand description
Compile-time type information for various reflected types.
Generally, for any given type, this value can be retrieved one of three ways:
Each return a static reference to TypeInfo
, but they all have their own use cases.
For example, if you know the type at compile time, Typed::type_info
is probably
the simplest. If all you have is a dyn Reflect
, you’ll probably want Reflect::get_represented_type_info
.
Lastly, if all you have is a TypeId
or type path, you will need to go through
TypeRegistry::get_type_info
.
You may also opt to use TypeRegistry::get_type_info
in place of the other methods simply because
it can be more performant. This is because those other methods may require attaining a lock on
the static TypeInfo
, while the registry simply checks a map.
Variants§
Struct(StructInfo)
TupleStruct(TupleStructInfo)
Tuple(TupleInfo)
List(ListInfo)
Array(ArrayInfo)
Map(MapInfo)
Enum(EnumInfo)
Value(ValueInfo)
Implementations§
Source§impl TypeInfo
impl TypeInfo
Sourcepub fn type_path_table(&self) -> &TypePathTable
pub fn type_path_table(&self) -> &TypePathTable
A representation of the type path of the underlying type.
Provides dynamic access to all methods on TypePath
.
Sourcepub fn type_path(&self) -> &'static str
pub fn type_path(&self) -> &'static str
The stable, full type path of the underlying type.
Use type_path_table
if you need access to the other methods on TypePath
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeInfo
impl !RefUnwindSafe for TypeInfo
impl Send for TypeInfo
impl Sync for TypeInfo
impl Unpin for TypeInfo
impl !UnwindSafe for TypeInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.