Skip to main content

UserDataMethods

Trait UserDataMethods 

Source
pub trait UserDataMethods<T> {
    // Required methods
    fn add_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
       where M: Fn(&Lua, &T, A) -> Result<R> + MaybeSend + 'static,
             A: FromLuaMulti,
             R: IntoLuaMulti;
    fn add_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
       where M: Fn(&Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
             A: FromLuaMulti,
             R: IntoLuaMulti;
    fn add_function<F, A, R>(&mut self, name: impl Into<String>, function: F)
       where F: Fn(&Lua, A) -> Result<R> + MaybeSend + 'static,
             A: FromLuaMulti,
             R: IntoLuaMulti;
    fn add_meta_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
       where M: Fn(&Lua, &T, A) -> Result<R> + MaybeSend + 'static,
             A: FromLuaMulti,
             R: IntoLuaMulti;
    fn add_meta_method_mut<M, A, R>(
        &mut self,
        name: impl Into<String>,
        method: M,
    )
       where M: Fn(&Lua, &mut T, A) -> Result<R> + MaybeSend + 'static,
             A: FromLuaMulti,
             R: IntoLuaMulti;
}
Expand description

Registrar passed to UserData::add_methods.

Mirrors mlua::UserDataMethods.

Required Methods§

Source

fn add_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
where M: Fn(&Lua, &T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti, R: IntoLuaMulti,

Register a method callable as obj:name(...); receives &T.

Source

fn add_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
where M: Fn(&Lua, &mut T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti, R: IntoLuaMulti,

Register a method callable as obj:name(...); receives &mut T.

Source

fn add_function<F, A, R>(&mut self, name: impl Into<String>, function: F)
where F: Fn(&Lua, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti, R: IntoLuaMulti,

Register a plain function in the userdata namespace (no self).

Source

fn add_meta_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
where M: Fn(&Lua, &T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti, R: IntoLuaMulti,

Register a meta-method (e.g. MetaMethod::Add, "__tostring"); receives &T.

Source

fn add_meta_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
where M: Fn(&Lua, &mut T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti, R: IntoLuaMulti,

Register a meta-method receiving &mut T.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§