Skip to main content

UserDataMethods

Trait UserDataMethods 

Source
pub trait UserDataMethods<T: UserData> {
    // Required methods
    fn add_method<A, R, F>(&mut self, name: &str, method: F)
       where A: FromLuaMulti + 'static,
             R: IntoLuaMulti + 'static,
             F: Fn(&Lua, &T, A) -> Result<R> + 'static;
    fn add_method_mut<A, R, F>(&mut self, name: &str, method: F)
       where A: FromLuaMulti + 'static,
             R: IntoLuaMulti + 'static,
             F: Fn(&Lua, &mut T, A) -> Result<R> + 'static;
    fn add_meta_method<A, R, F>(&mut self, metamethod: MetaMethod, method: F)
       where A: FromLuaMulti + 'static,
             R: IntoLuaMulti + 'static,
             F: Fn(&Lua, &T, A) -> Result<R> + 'static;
    fn add_meta_method_mut<A, R, F>(
        &mut self,
        metamethod: MetaMethod,
        method: F,
    )
       where A: FromLuaMulti + 'static,
             R: IntoLuaMulti + 'static,
             F: Fn(&Lua, &mut T, A) -> Result<R> + 'static;
    fn add_field_method_get<R, F>(&mut self, name: &str, getter: F)
       where R: IntoLuaMulti + 'static,
             F: Fn(&Lua, &T) -> Result<R> + 'static;
    fn add_field_method_set<A, F>(&mut self, name: &str, setter: F)
       where A: FromLuaMulti + 'static,
             F: Fn(&Lua, &mut T, A) -> Result<()> + 'static;
}

Required Methods§

Source

fn add_method<A, R, F>(&mut self, name: &str, method: F)
where A: FromLuaMulti + 'static, R: IntoLuaMulti + 'static, F: Fn(&Lua, &T, A) -> Result<R> + 'static,

Source

fn add_method_mut<A, R, F>(&mut self, name: &str, method: F)
where A: FromLuaMulti + 'static, R: IntoLuaMulti + 'static, F: Fn(&Lua, &mut T, A) -> Result<R> + 'static,

Source

fn add_meta_method<A, R, F>(&mut self, metamethod: MetaMethod, method: F)
where A: FromLuaMulti + 'static, R: IntoLuaMulti + 'static, F: Fn(&Lua, &T, A) -> Result<R> + 'static,

Source

fn add_meta_method_mut<A, R, F>(&mut self, metamethod: MetaMethod, method: F)
where A: FromLuaMulti + 'static, R: IntoLuaMulti + 'static, F: Fn(&Lua, &mut T, A) -> Result<R> + 'static,

Source

fn add_field_method_get<R, F>(&mut self, name: &str, getter: F)
where R: IntoLuaMulti + 'static, F: Fn(&Lua, &T) -> Result<R> + 'static,

Register a getter for obj.name. The runtime composes all field getters, the method table, and any raw __index into a single __index so fields and methods coexist (lookup order: field, then method, then raw __index).

Source

fn add_field_method_set<A, F>(&mut self, name: &str, setter: F)
where A: FromLuaMulti + 'static, F: Fn(&Lua, &mut T, A) -> Result<()> + 'static,

Register a setter for obj.name = value. Assigning a field with no setter (or an unknown field) errors unless a raw __newindex handles it.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§