pub enum Type {
    Single(Cow<'static, str>),
    Value(Box<Type>),
    Alias(Box<Type>),
    Tuple(Vec<Type>),
    Table(BTreeMap<Index, Type>),
    Union(Vec<Type>),
    Array(Box<Type>),
    Map(Box<Type>, Box<Type>),
    Function {
        params: Vec<Param>,
        returns: Vec<Return>,
    },
    Enum(Vec<Type>),
    Class(Box<TypedClassBuilder>),
    Module(Box<TypedModuleBuilder>),
}Expand description
Representation of a lua type for a rust type
Variants§
Single(Cow<'static, str>)
Represents a single type. i.e. string, number, 0, "literal", Example, etc…
§Example
--- @type string
--- @type number 
--- @type 0
--- @type "literal"
--- @type ExampleValue(Box<Type>)
Alias(Box<Type>)
Tuple(Vec<Type>)
Table(BTreeMap<Index, Type>)
Union(Vec<Type>)
Array(Box<Type>)
Map(Box<Type>, Box<Type>)
Function
Represents a function with it’s parameters and return types
§Example
--- @type fun(self: any, name: string): stringEnum(Vec<Type>)
References a enum type.
In this instance it acts like a union since that is the closest relation between rust enums and a lua type
§Example
--- @alias {name} {type}
---  | {type}
---  | {type}
---  | {type}Class(Box<TypedClassBuilder>)
Represents a class type
§Example
--- @class {name}
--- @field name string
--- @field age integer 
--- @field height numberModule(Box<TypedModuleBuilder>)
Represents a global table (module)
§Example
module = {
    data = nil,
    method = function(self) end,
}or flattened
module = {}
function module:method() end
module.data = nilImplementations§
Source§impl Type
 
impl Type
Sourcepub const fn is_function(&self) -> bool
 
pub const fn is_function(&self) -> bool
Returns true if the enum is Type::Function otherwise false
Source§impl Type
 
impl Type
Sourcepub fn literal<T: IntoLuaTypeLiteral>(value: T) -> Self
 
pub fn literal<T: IntoLuaTypeLiteral>(value: T) -> Self
Create a lua type literal from a rust value. i.e. 3, true, etc…
Sourcepub fn named(value: impl Into<Cow<'static, str>>) -> Self
 
pub fn named(value: impl Into<Cow<'static, str>>) -> Self
Create a references the name of another defined type.
§Example
--- @class Example
--- @type Example
example = niluse mlua_extras::typed::Type;
// This references the type named `Example`
Type::named("Example")Sourcepub fn lightuserdata() -> Self
 
pub fn lightuserdata() -> Self
Create a lua builtin lightuserdata type
Sourcepub fn enum(types: impl IntoIterator<Item = Type>) -> Self
 
pub fn enum(types: impl IntoIterator<Item = Type>) -> Self
Create an enum type. This is equal to an alias
Sourcepub fn map(key: Type, value: Type) -> Self
 
pub fn map(key: Type, value: Type) -> Self
Create a type that is an array. i.e. { [integer]: type }
Sourcepub fn union(types: impl IntoIterator<Item = Type>) -> Self
 
pub fn union(types: impl IntoIterator<Item = Type>) -> Self
Create a type that is a union. i.e. string | integer | nil
Sourcepub fn tuple(types: impl IntoIterator<Item = Type>) -> Self
 
pub fn tuple(types: impl IntoIterator<Item = Type>) -> Self
create a type that is a tuple. i.e. { [1]: type, [2]: type }
Sourcepub fn class(class: TypedClassBuilder) -> Self
 
pub fn class(class: TypedClassBuilder) -> Self
create a type that is a class. i.e. --- @class {name}
Sourcepub fn module(module: TypedModuleBuilder) -> Self
 
pub fn module(module: TypedModuleBuilder) -> Self
create a type that is a global module
Sourcepub fn function<Params: TypedMultiValue, Response: TypedMultiValue>() -> Self
 
pub fn function<Params: TypedMultiValue, Response: TypedMultiValue>() -> Self
create a type that is a function. i.e. fun(self): number
Trait Implementations§
Source§impl<T: Into<Type>> BitOr<T> for Type
Allows to union types
 
impl<T: Into<Type>> BitOr<T> for Type
Allows to union types
§Example
use mlua_extras::typed::Type;
Type::string() | Type::nil()