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§
Sourcefn add_field<V>(&mut self, name: impl Into<String>, value: V)
fn add_field<V>(&mut self, name: impl Into<String>, value: V)
Register a constant field value (read-only).
Sourcefn add_field_method_get<M, R>(&mut self, name: impl Into<String>, method: M)
fn add_field_method_get<M, R>(&mut self, name: impl Into<String>, method: M)
Register a field whose getter receives &T.
Sourcefn add_field_method_set<M, A>(&mut self, name: impl Into<String>, method: M)
fn add_field_method_set<M, A>(&mut self, name: impl Into<String>, method: M)
Register a field whose setter receives &mut T and the assigned value.
Sourcefn add_field_function_get<F, R>(&mut self, name: impl Into<String>, function: F)
fn add_field_function_get<F, R>(&mut self, name: impl Into<String>, function: F)
Register a field whose getter receives the AnyUserData handle.
Sourcefn add_field_function_set<F, A>(&mut self, name: impl Into<String>, function: F)
fn add_field_function_set<F, A>(&mut self, name: impl Into<String>, function: F)
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".