pub struct DefinitionBuilder {
    pub entries: Vec<Entry>,
}Expand description
Builder for definition entries
Fields§
§entries: Vec<Entry>Implementations§
Source§impl DefinitionBuilder
 
impl DefinitionBuilder
Sourcepub fn function<'lua, Params, Returns>(
    self,
    name: impl Display,
    _: impl IntoTypedFunction<'lua, Params, Returns>,
) -> Selfwhere
    Params: TypedMultiValue,
    Returns: TypedMultiValue,
 
pub fn function<'lua, Params, Returns>(
    self,
    name: impl Display,
    _: impl IntoTypedFunction<'lua, Params, Returns>,
) -> Selfwhere
    Params: TypedMultiValue,
    Returns: TypedMultiValue,
Register a definition entry that is a function type
Sourcepub fn function_with<'lua, Params, Returns, F>(
    self,
    name: impl Display,
    _: impl IntoTypedFunction<'lua, Params, Returns>,
    generator: F,
) -> Selfwhere
    Params: TypedMultiValue,
    Returns: TypedMultiValue,
    F: Fn(&mut FunctionBuilder<Params, Returns>),
 
pub fn function_with<'lua, Params, Returns, F>(
    self,
    name: impl Display,
    _: impl IntoTypedFunction<'lua, Params, Returns>,
    generator: F,
) -> Selfwhere
    Params: TypedMultiValue,
    Returns: TypedMultiValue,
    F: Fn(&mut FunctionBuilder<Params, Returns>),
Register a definition entry that is a function type
Also add additional documentation
Sourcepub fn register_as(
    self,
    name: impl Into<Cow<'static, str>>,
    ty: impl Into<Type>,
) -> Self
 
pub fn register_as( self, name: impl Into<Cow<'static, str>>, ty: impl Into<Type>, ) -> Self
Register a already built type.
Sourcepub fn module<T: TypedModule>(self, name: impl Display) -> Self
 
pub fn module<T: TypedModule>(self, name: impl Display) -> Self
Register a definition entry that is a class type
The name of the class is the same as the name of the type passed
Sourcepub fn module_with<T: TypedModule, S: Display>(
    self,
    name: impl Display,
    doc: Option<S>,
) -> Self
 
pub fn module_with<T: TypedModule, S: Display>( self, name: impl Display, doc: Option<S>, ) -> Self
Same as module but with additional docs
Sourcepub fn value<T: Typed>(self, name: impl Display) -> Self
 
pub fn value<T: Typed>(self, name: impl Display) -> Self
Register a value that is available
This can be a table, union/enum, literal, or any other value and it will be typed with the given type
§Example
user mlua_extras::{typed::{Definitions, TypedUserData}, Typed, UserData};
#[derive(UserData, Typed)]
struct Example {
    color: String
}
impl TypedUserData for Example {
    fn add_documentation<F: mlua_extras::typed::TypedDataDocumentation<Self>>(docs: &mut F) {
        docs.add("This is an example");
    }
     
    fn add_fields<'lua, F: TypedDataFields<'lua, Self>>(fields: &mut F) {
        fields
            .document("Example field")
            .add_field_method_get_set(
                "color",
                |_lua, this| Ok(this.color),
                |_lua, this, clr: String| {
                    this.color = clr;
                    Ok(())
                },
            );
    }
}
Definitions::generate("init")
    .register::<Example>("Example")
    .value::<Example>("example")
    .finish();--- init.d.lua
--- @meta
--- This is an example
--- @class Example
--- Example field
--- @field color string
--- The example module
--- @type Example
example = nilSourcepub fn value_with<T: Typed, S: Display>(
    self,
    name: impl Display,
    doc: Option<S>,
) -> Self
 
pub fn value_with<T: Typed, S: Display>( self, name: impl Display, doc: Option<S>, ) -> Self
Same as value but with additional docs
Sourcepub fn finish(self) -> Definition
 
pub fn finish(self) -> Definition
Finish the definition
Trait Implementations§
Source§impl Clone for DefinitionBuilder
 
impl Clone for DefinitionBuilder
Source§fn clone(&self) -> DefinitionBuilder
 
fn clone(&self) -> DefinitionBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moreSource§impl Debug for DefinitionBuilder
 
impl Debug for DefinitionBuilder
Source§impl Default for DefinitionBuilder
 
impl Default for DefinitionBuilder
Source§fn default() -> DefinitionBuilder
 
fn default() -> DefinitionBuilder
Returns the “default value” for a type. Read more
Source§impl From<DefinitionBuilder> for Definition
 
impl From<DefinitionBuilder> for Definition
Source§fn from(value: DefinitionBuilder) -> Self
 
fn from(value: DefinitionBuilder) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for DefinitionBuilder
impl RefUnwindSafe for DefinitionBuilder
impl Send for DefinitionBuilder
impl Sync for DefinitionBuilder
impl Unpin for DefinitionBuilder
impl UnwindSafe for DefinitionBuilder
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