[−][src]Enum rebound::ty::Type
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]
pub fn name(&self) -> String
[src]
pub fn assoc_fns(&self) -> Vec<AssocFn>
[src]
pub fn assoc_consts(&self) -> Vec<AssocConst>
[src]
pub fn as_ref<'a>(&self, val: &'a Value<'_>) -> Result<Value<'a>, Error>
[src]
pub fn as_mut<'a>(&self, val: &'a mut Value<'_>) -> Result<Value<'a>, Error>
[src]
impl Copy for Type
[src]
impl Debug for Type
[src]
impl Eq for Type
[src]
impl Hash for Type
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Type> for Type
[src]
Auto Trait Implementations
impl RefUnwindSafe for Type
[src]
impl Send for Type
[src]
impl Sync for Type
[src]
impl Unpin for Type
[src]
impl UnwindSafe for Type
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,