TypeInfoDynamic

Trait TypeInfoDynamic 

Source
pub trait TypeInfoDynamic: Any {
    // Required methods
    fn get_dynamic(&self) -> &'static Type;
    fn construct_struct(
        &self,
        args: Vec<Box<dyn Any>>,
    ) -> Result<Box<dyn Any>, RuntimeConstructError>;
    fn construct_enum(
        &self,
        variant: &'static str,
        args: Vec<Box<dyn Any>>,
    ) -> Result<Box<dyn Any>, RuntimeConstructError>;
    fn field<'s>(
        &'s self,
        id: FieldId,
    ) -> Result<Unsizeable<'s>, FieldAccessError>;
    fn field_mut<'s>(
        &'s mut self,
        id: FieldId,
    ) -> Result<UnsizeableMut<'s>, FieldAccessError>;
}
Expand description

Object-safe version of TypeInfo

Additionally provides ability to construct type (if it’s not a enum without variants), and ability to borrow (both immutably and mutably) fields

Required Methods§

Source

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

Get Type information for this type

Because it accepts reference to self, it can be called on [dyn] trait-objects

Source

fn construct_struct( &self, args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Constructs this type if it is a struct

Attempts to downcast passed arguments to type of fields. Multiple fields can be of same type, just make sure that order is preserved or you might get unexpected results

If called on enum type, RuntimeConstructError::NotStruct will be returned

Note: Arguments must be passed in same order as definition order of fields inside struct

Source

fn construct_enum( &self, variant: &'static str, args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Constructs Self if it is enum

Attempts to downcast passed arguments as type of fields of requested variant, if there are any. List of required arguments is target variant-dependent, as well as their order

If variant is unit, no arguments will be required aside from variant

Note: Arguments must be passed in same order as definition order of fields inside of particular variant

Source

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Borrow immutably field inside this type

Type must not be a unit and id must be valid in terms of this type (present)

Returns Unsizeable, which can further be downcast to “nameable” type

Source

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Borrow mutably field inside this type

Same as [TypeInfo::field], except that returned “reference” is mutable

Implementations on Foreign Types§

Source§

impl TypeInfoDynamic for f32

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for f64

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for i8

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for i16

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for i32

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for i64

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for i128

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for isize

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for u8

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for u16

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for u32

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for u64

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for u128

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for usize

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Source§

impl TypeInfoDynamic for String

Source§

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

Source§

fn construct_struct( &self, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn construct_enum( &self, _variant: &'static str, _args: Vec<Box<dyn Any>>, ) -> Result<Box<dyn Any>, RuntimeConstructError>

Source§

fn field<'s>(&'s self, id: FieldId) -> Result<Unsizeable<'s>, FieldAccessError>

Source§

fn field_mut<'s>( &'s mut self, id: FieldId, ) -> Result<UnsizeableMut<'s>, FieldAccessError>

Implementors§