pub trait TypeName {
// Required method
fn get_type_parts() -> Cow<'static, [NamePart]>;
// Provided methods
fn get_type_parts_as_global() -> Cow<'static, [NamePart]> { ... }
fn get_type_kind() -> KindOfType { ... }
fn collect_children(_: &mut Vec<TealType>) { ... }
}
Expand description
A trait to collect the required type information like the name of the type.
Required Methods§
sourcefn get_type_parts() -> Cow<'static, [NamePart]>
fn get_type_parts() -> Cow<'static, [NamePart]>
returns the type name as how it should show up in the generated .d.tl
file
Provided Methods§
sourcefn get_type_parts_as_global() -> Cow<'static, [NamePart]>
fn get_type_parts_as_global() -> Cow<'static, [NamePart]>
Generates the typename when used to describe a global value.
Sometimes (for example in the case of lambda’s with types marked as generic) you want an altered representation of the type if it is used as a global instance or is part of something else.
You almost never want this though so you should probably think twice before altering the implementation.
sourcefn get_type_kind() -> KindOfType
fn get_type_kind() -> KindOfType
This method tells the generator if this type is builtin to teal/lua, if it comes from somewhere else or if it stands in as a generic
In almost all cases you want to return KindOfType::External
KindOfType::Generic` is only needed if the type itself is meant as a generic type placeholder.
sourcefn collect_children(_: &mut Vec<TealType>)
fn collect_children(_: &mut Vec<TealType>)
Creates/updates a list of every child type this type has This is used to properly label methods/functions as being generic.