[][src]Enum rebound::ty::Type

pub enum Type {
    Primitive(PrimitiveInfo),
    Tuple(TupleInfo),
    Array(ArrayInfo),
    Slice(SliceInfo),
    Pointer(PointerInfo),
    Reference(ReferenceInfo),
    Function(FunctionInfo),
    Struct(StructInfo),
    TupleStruct(TupleStructInfo),
    UnitStruct(UnitStructInfo),
    Enum(EnumInfo),
    Union(UnionInfo),
}

An enum that represents information about a reflected type. This supports basically any possible type in Rust, including primitives, arrays, and references. Generally, the only requirement is that the type implement the Reflected trait, though most types are also expected to implement another trait related to information they possess not shared by other type kinds.

This is not, and cannot, be backed by core::any::TypeId, because that is only valid on 'static types, while this works with dynamic lifetimes.

Variants

Primitive(PrimitiveInfo)

A primitive simple type, such as u8 or str

Tuple(TupleInfo)

A tuple type, (T0, .., Tn)

Array(ArrayInfo)

An array type, [T; N]

Slice(SliceInfo)

A slice type, [T]

Pointer(PointerInfo)

A pointer type, either *const T or *mut T

Reference(ReferenceInfo)

A reference type, either &T or &mut T

Function(FunctionInfo)

A function pointer type, fn(T1..Tn) -> T0

Struct(StructInfo)

A struct type, with named fields

TupleStruct(TupleStructInfo)

A struct type, with unnamed fields

UnitStruct(UnitStructInfo)

A struct type, with no fields

Enum(EnumInfo)

An enum type, with variants

Union(UnionInfo)

A union type, with fields

Implementations

impl Type[src]

pub unsafe fn new_struct<T: ?Sized + ReflectedStruct>()[src]

Internal function used by generated code to initialize a Type for structs

Safety

Should only be called inside a Reflected type's init impl

pub unsafe fn new_tuple_struct<T: ReflectedTupleStruct>()[src]

Internal function used by generated code to initialize a Type for tuple structs

Safety

Should only be called inside a Reflected type's init impl

pub unsafe fn new_unit_struct<T: ReflectedUnitStruct>()[src]

Internal function used by generated code to initialize a Type for unit structs

Safety

Should only be called inside a Reflected type's init impl

pub unsafe fn new_enum<T: ReflectedEnum>()[src]

Internal function used by generated code to initialize a Type for enums

Safety

Should only be called inside a Reflected type's init impl

pub unsafe fn new_union<T: ReflectedUnion>()[src]

Internal function used by generated code to initialize a Type for unions

Safety

Should only be called inside a Reflected type's init impl

pub unsafe fn from_name(name: &str) -> Option<Type>[src]

Get a Type instance by name, assuming it has been instantiated beforehand. The name provided is expected to be of a certain normalized form, which may not be fully stable between versions. Prefer Type::from if possible.

Current Requirements:

  • All struct names should be fully qualified, so for example the Type for Type would be rebound::ty::Type
  • Any commas will be followed by spaces, and there will be no trailing commas except in the case of 1-element tuples
  • References will have no lifetime
  • Possibly other things

Safety

This function is in no way memory unsafe, however, the format used for type names is an implementation detail, and thus may change even across patch versions.

pub fn from<T: ?Sized + Reflected>() -> Type[src]

Get a Type instance from any reflected type, instantiating it if necessary.

pub fn unwrap_primitive(&self) -> &PrimitiveInfo[src]

Get this Type as a PrimitiveInfo, panicking on failure.

pub fn unwrap_tuple(&self) -> &TupleInfo[src]

Get this Type as a TupleInfo, panicking on failure.

pub fn unwrap_array(&self) -> &ArrayInfo[src]

Get this Type as a ArrayInfo, panicking on failure.

pub fn unwrap_slice(&self) -> &SliceInfo[src]

Get this Type as a SliceInfo, panicking on failure.

pub fn unwrap_pointer(&self) -> &PointerInfo[src]

Get this Type as a PointerInfo, panicking on failure.

pub fn unwrap_reference(&self) -> &ReferenceInfo[src]

Get this Type as a ReferenceInfo, panicking on failure.

pub fn unwrap_function(&self) -> &FunctionInfo[src]

Get this Type as a FunctionInfo, panicking on failure.

pub fn unwrap_struct(&self) -> &StructInfo[src]

Get this Type as a StructInfo, panicking on failure.

pub fn unwrap_tuple_struct(&self) -> &TupleStructInfo[src]

Get this Type as a TupleStructInfo, panicking on failure.

pub fn unwrap_unit_struct(&self) -> &UnitStructInfo[src]

Get this Type as a UnitStructInfo, panicking on failure.

pub fn unwrap_enum(&self) -> &EnumInfo[src]

Get this Type as a EnumInfo, panicking on failure.

pub fn unwrap_union(&self) -> &UnionInfo[src]

Get this Type as a UnionInfo, panicking on failure.

Trait Implementations

impl Clone for Type[src]

impl CommonTypeInfo for Type[src]

impl Copy for Type[src]

impl Debug for Type[src]

impl Eq for Type[src]

impl Hash for Type[src]

impl PartialEq<Type> for Type[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.