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§
Provided Methods§
Sourcefn doc() -> Option<&'static str>
fn doc() -> Option<&'static str>
Any documentation for this type. Mostly set for derive macros.
Sourcefn fields() -> Vec<Field>
fn fields() -> Vec<Field>
Any fields that should be treated as part of this struct. Only really makes sense to derive.
Sourcefn nullable() -> bool
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.
Sourcefn variant_fields() -> Vec<Field>
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.
Sourcefn flatten_fields() -> Vec<Field>
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<T1: TypeInfo> TypeInfo for (T1,)
This trait is implemented for tuples up to 5 items long.
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.
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.
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.
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.
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.
impl<T: TypeInfo> TypeInfo for Option<T>
An Option