Enum static_reflect::types::TypeInfo[][src]

pub enum TypeInfo<'a> {
Show variants Unit, Never, Bool, Integer { size: IntSize, signed: bool, }, Float { size: FloatSize, }, Slice { element_type: &'a TypeInfo<'a>, }, Str, Optional(&'a TypeInfo<'a>), Pointer, Structure(&'a StructureDef<'a>), Union(&'a UnionDef<'a>), Extern { name: &'static str, }, Magic { id: &'static &'static str, extra: Option<&'a TypeInfo<'a>>, },
}

A type whose representation is known via reflection

These are usually defined statically via [StaticReflect

However, they can be allocated at runtime, and potentially live for a more limited lifetime.

Variants

Unit

The zero-length unit type ()

Used for functions that return nothing

Never

An impossible type,

The mere existence of this type at runtime is undefined behavior. Functions that have this as their return type never actually return.

Bool

A boolean

Like a Rust bool, values must be either zero or one. Anything else is undefined behavior.

Integer

An integer

Show fields

Fields of Integer

size: IntSize

The size of the integer

signed: bool

If the integer is signed

Float

A floating point number

Show fields

Fields of Float

size: FloatSize

The size/precision of the float

Slice

A slice of memory, represented as pointer + length

The element type is needed, since array indexing implicitly multiples by the size of the memory.

Representation should match the AsmSlice type

Show fields

Fields of Slice

element_type: &'a TypeInfo<'a>

The type of the inner element

Str

A pointer to a UTF8 encoded string and length, just like Rust’s ‘str’ type

Internally represented by the AsmStr structure

Optional(&'a TypeInfo<'a>)

A very simple optional, represented as an AsmOption

This never uses the null pointer optimization

Pointer

An untyped pointer

This may be null.

Untyped pointers simplify the type system significantly. They also avoid cycles when defining structures in case a structure contains a pointer to itself.

Structure(&'a StructureDef<'a>)

A structure

Union(&'a UnionDef<'a>)

An untagged union

Extern

A named, transparent, extern type

Show fields

Fields of Extern

name: &'static str

The name of the type

Since this is all we have, it’s what used to disambiguate between them.

Magic

A ‘magic’ type, with a user-defined meaning

This allows extensions to the type system

Show fields

Fields of Magic

id: &'static &'static str

The id of the magic type, giving more information about how its implemented and what it actually means.

extra: Option<&'a TypeInfo<'a>>

Extra information (if any)

Implementations

impl TypeInfo<'static>[src]

pub const F32: Self[src]

A 32-bit, single-precision float

pub const F64: Self[src]

A 64-bit, double-precision float

pub const fn integer(size: usize, signed: bool) -> Self[src]

An integer with the specified size and signed-ness

Panics if the size is invalid

impl<'tp> TypeInfo<'tp>[src]

pub const fn size(&self) -> usize[src]

The size of the type, in bytes

pub const fn alignment(&self) -> usize[src]

The alignment of the type, matching std::mem::align_of

Trait Implementations

impl<'a> Clone for TypeInfo<'a>[src]

impl<'a> Copy for TypeInfo<'a>[src]

impl<'a> Debug for TypeInfo<'a>[src]

impl<'a> Display for TypeInfo<'a>[src]

impl<'a> Eq for TypeInfo<'a>[src]

impl<'tp> From<&'tp TypeInfo<'tp>> for TypeId<'tp>[src]

impl<'a> Hash for TypeInfo<'a>[src]

impl<'a> PartialEq<TypeInfo<'a>> for TypeInfo<'a>[src]

impl<'a> StructuralEq for TypeInfo<'a>[src]

impl<'a> StructuralPartialEq for TypeInfo<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for TypeInfo<'a>

impl<'a> Send for TypeInfo<'a>

impl<'a> Sync for TypeInfo<'a>

impl<'a> Unpin for TypeInfo<'a>

impl<'a> UnwindSafe for TypeInfo<'a>

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> ToString for T where
    T: Display + ?Sized
[src]

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.