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§
Sourcefn add_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
fn add_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
Register a method callable as obj:name(...); receives &T.
Sourcefn add_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
fn add_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
Register a method callable as obj:name(...); receives &mut T.
Sourcefn add_function<F, A, R>(&mut self, name: impl Into<String>, function: F)
fn add_function<F, A, R>(&mut self, name: impl Into<String>, function: F)
Register a plain function in the userdata namespace (no self).
Sourcefn add_meta_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
fn add_meta_method<M, A, R>(&mut self, name: impl Into<String>, method: M)
Register a meta-method (e.g. MetaMethod::Add, "__tostring");
receives &T.
Sourcefn add_meta_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
fn add_meta_method_mut<M, A, R>(&mut self, name: impl Into<String>, method: M)
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".