TypeInfo

Trait TypeInfo 

Source
pub trait TypeInfo {
    // Required method
    fn kind() -> Kind;

    // Provided methods
    fn doc() -> Option<&'static str> { ... }
    fn fields() -> Vec<Field> { ... }
    fn nullable() -> bool { ... }
    fn item() -> Item { ... }
    fn variant_fields() -> Vec<Field> { ... }
    fn flatten_fields() -> Vec<Field> { ... }
}
Expand description

A trait for types that can be reflected on.

All of the methods here except for kind have default impls for simple types and should not be overridden unless you know what you’re doing.

Required Methods§

Source

fn kind() -> Kind

The Kind of this type.

Provided Methods§

Source

fn doc() -> Option<&'static str>

Any documentation for this type. Mostly set for derive macros.

Source

fn fields() -> Vec<Field>

Any fields that should be treated as part of this struct. Only really makes sense to derive.

Source

fn nullable() -> bool

Whether or not this field can be nullable.

This should only ever be set for Option, and doing otherwise is a crime.

Source

fn item() -> Item

Bundle all of the info about this type into an Item.

Source

fn variant_fields() -> Vec<Field>

Any fields defined in Union variants. This must be empty for any types with a Kind that is not Kind::Union.

Source

fn flatten_fields() -> Vec<Field>

The fields that should be included when this type is flattened with serde(flatten).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TypeInfo for &'static str

Source§

impl TypeInfo for bool

Source§

impl TypeInfo for f32

Source§

impl TypeInfo for f64

Source§

impl TypeInfo for i8

Source§

impl TypeInfo for i16

Source§

impl TypeInfo for i32

Source§

impl TypeInfo for u8

Source§

impl TypeInfo for u16

Source§

impl TypeInfo for u32

Source§

impl TypeInfo for String

Source§

impl<K: TypeInfo, V: TypeInfo> TypeInfo for BTreeMap<K, V>

Source§

impl<T1: TypeInfo> TypeInfo for (T1,)

This trait is implemented for tuples up to 5 items long.

Source§

impl<T1: TypeInfo, T2: TypeInfo> TypeInfo for (T1, T2)

This trait is implemented for tuples up to 5 items long.

Source§

impl<T1: TypeInfo, T2: TypeInfo, T3: TypeInfo> TypeInfo for (T1, T2, T3)

This trait is implemented for tuples up to 5 items long.

Source§

impl<T1: TypeInfo, T2: TypeInfo, T3: TypeInfo, T4: TypeInfo> TypeInfo for (T1, T2, T3, T4)

This trait is implemented for tuples up to 5 items long.

Source§

impl<T1: TypeInfo, T2: TypeInfo, T3: TypeInfo, T4: TypeInfo, T5: TypeInfo> TypeInfo for (T1, T2, T3, T4, T5)

This trait is implemented for tuples up to 5 items long.

Source§

impl<T: TypeInfo> TypeInfo for Option<T>

An Option is the same as a nullable T in our target languages.

Source§

impl<T: TypeInfo> TypeInfo for Vec<T>

A Vec wraps the Kind of the T’s it contains.

Implementors§