Enum mlua_extras::typed::Type
source · pub enum Type {
Single(Cow<'static, str>),
Value(Box<Type>),
Alias(Box<Type>),
Enum(Cow<'static, str>, Vec<Type>),
Class(Box<Class>),
Tuple(Vec<Type>),
Struct(BTreeMap<&'static str, Type>),
Variadic(Box<Type>),
Union(Vec<Type>),
Array(Box<Type>),
Map(Box<Type>, Box<Type>),
Function {
params: Vec<Param>,
returns: Vec<Type>,
},
}
Expand description
Representation of a lua type for a rust type
Variants§
Single(Cow<'static, str>)
string nil boolean “literal” 3 … etc
Value(Box<Type>)
Alias(Box<Type>)
— @alias {name}
Enum(Cow<'static, str>, Vec<Type>)
Same as alias but with a set name predefined
— @alias {name}
Class(Box<Class>)
— @class {name} — @field …
Tuple(Vec<Type>)
{ [1]:
Struct(BTreeMap<&'static str, Type>)
Variadic(Box<Type>)
Union(Vec<Type>)
Array(Box<Type>)
Map(Box<Type>, Box<Type>)
Function
Implementations§
source§impl Type
impl Type
sourcepub fn literal_string<T: Display>(value: T) -> Self
pub fn literal_string<T: Display>(value: T) -> Self
Create a lua type literal for a string. i.e. "string"
sourcepub fn literal<T: Display>(value: T) -> Self
pub fn literal<T: Display>(value: T) -> Self
Create a lua type literal from a rust value. i.e. 3
, true
, etc…
sourcepub fn single(value: impl Into<Cow<'static, str>>) -> Self
pub fn single(value: impl Into<Cow<'static, str>>) -> Self
Create a type that has a single value. i.e. string
, number
, etc…
sourcepub fn enum(
name: impl Into<Cow<'static, str>>,
types: impl IntoIterator<Item = Type>,
) -> Self
pub fn enum( name: impl Into<Cow<'static, str>>, types: impl IntoIterator<Item = Type>, ) -> Self
Create an enum type. This is equal to an alias
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<T: TypedUserData>() -> Self
pub fn class<T: TypedUserData>() -> Self
create a type that is a class. i.e. --- @class {name}
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 BitOr for Type
impl BitOr for Type
Allows to union types
§Example
use mlua_extras::typed::Type;
Type::single("string") | Type::single("nil")
source§impl Ord for Type
impl Ord for Type
source§impl PartialOrd for Type
impl PartialOrd for Type
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)