Skip to main content

UserDataFields

Trait UserDataFields 

Source
pub trait UserDataFields<T> {
    // Required methods
    fn add_field<V>(&mut self, name: impl Into<String>, value: V)
       where V: IntoLua + Clone + MaybeSend + 'static;
    fn add_field_method_get<M, R>(&mut self, name: impl Into<String>, method: M)
       where M: Fn(&Lua, &T) -> Result<R> + MaybeSend + 'static,
             R: IntoLua;
    fn add_field_method_set<M, A>(&mut self, name: impl Into<String>, method: M)
       where M: Fn(&Lua, &mut T, A) -> Result<()> + MaybeSend + 'static,
             A: FromLua;
    fn add_field_function_get<F, R>(
        &mut self,
        name: impl Into<String>,
        function: F,
    )
       where F: Fn(&Lua, AnyUserData) -> Result<R> + MaybeSend + 'static,
             R: IntoLua;
    fn add_field_function_set<F, A>(
        &mut self,
        name: impl Into<String>,
        function: F,
    )
       where F: Fn(&Lua, AnyUserData, A) -> Result<()> + MaybeSend + 'static,
             A: FromLua;
}
Expand description

Registrar passed to UserData::add_fields.

Mirrors mlua::UserDataFields. Field getters/setters are dispatched by the userdata’s __index/__newindex.

Required Methods§

Source

fn add_field<V>(&mut self, name: impl Into<String>, value: V)
where V: IntoLua + Clone + MaybeSend + 'static,

Register a constant field value (read-only).

Source

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

Register a field whose getter receives &T.

Source

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

Register a field whose setter receives &mut T and the assigned value.

Source

fn add_field_function_get<F, R>(&mut self, name: impl Into<String>, function: F)
where F: Fn(&Lua, AnyUserData) -> Result<R> + MaybeSend + 'static, R: IntoLua,

Register a field whose getter receives the AnyUserData handle.

Source

fn add_field_function_set<F, A>(&mut self, name: impl Into<String>, function: F)
where F: Fn(&Lua, AnyUserData, A) -> Result<()> + MaybeSend + 'static, A: FromLua,

Register a field whose setter receives the AnyUserData handle and the assigned value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§