Struct rlua::LuaUserDataMethods
[−]
[src]
pub struct LuaUserDataMethods<T> { /* fields omitted */ }
Stores methods of a userdata object.
Methods added will be added to the __index
table on the metatable for the userdata, so they
can be called as userdata:method(args)
as expected. If there are any regular methods, and an
Index
metamethod is given, it will be called as a fallback if the index doesn't match an
existing regular method.
Methods
impl<T: LuaUserDataType> LuaUserDataMethods<T>
[src]
fn add_method<M>(&mut self, name: &str, method: M) where
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a regular method as a function which accepts a &T as the first parameter.
fn add_method_mut<M>(&mut self, name: &str, method: M) where
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a mut T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a mut T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a regular method as a function which accepts a &mut T as the first parameter.
fn add_function<F>(&mut self, name: &str, function: F) where
F: 'static + for<'a, 'lua> FnMut(&'lua Lua, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
F: 'static + for<'a, 'lua> FnMut(&'lua Lua, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a regular method as a function which accepts generic arguments, the first argument will always be a LuaUserData of type T.
fn add_meta_method<M>(&mut self, meta: LuaMetaMethod, method: M) where
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a metamethod as a function which accepts a &T as the first parameter. This can cause an error with certain binary metamethods that can trigger if ony the right side has a metatable.
fn add_meta_method_mut<M>(&mut self, meta: LuaMetaMethod, method: M) where
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a mut T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
M: 'static + for<'a, 'lua> FnMut(&'lua Lua, &'a mut T, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a metamethod as a function which accepts a &mut T as the first parameter. This can cause an error with certain binary metamethods that can trigger if ony the right side has a metatable.
fn add_meta_function<F>(&mut self, meta: LuaMetaMethod, function: F) where
F: 'static + for<'a, 'lua> FnMut(&'lua Lua, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
F: 'static + for<'a, 'lua> FnMut(&'lua Lua, LuaMultiValue<'lua>) -> LuaResult<LuaMultiValue<'lua>>,
Add a metamethod as a function which accepts generic arguments. Metamethods in Lua for binary operators can be triggered if either the left or right argument to the binary operator has a metatable, so the first argument here is not necessarily a userdata of type T.