Trait rlua::AnyUserDataExt
source · pub trait AnyUserDataExt<'lua>: Sealed {
// Required methods
fn get<K, V>(&self, key: K) -> Result<V, Error>
where K: IntoLua<'lua>,
V: FromLua<'lua>;
fn set<K, V>(&self, key: K, value: V) -> Result<(), Error>
where K: IntoLua<'lua>,
V: IntoLua<'lua>;
fn call<A, R>(&self, args: A) -> Result<R, Error>
where A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R, Error>
where A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R, Error>
where A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
}
Expand description
An extension trait for AnyUserData
that provides a variety of convenient functionality.
Required Methods§
sourcefn get<K, V>(&self, key: K) -> Result<V, Error>
fn get<K, V>(&self, key: K) -> Result<V, Error>
Gets the value associated to key
from the userdata, assuming it has __index
metamethod.
sourcefn set<K, V>(&self, key: K, value: V) -> Result<(), Error>
fn set<K, V>(&self, key: K, value: V) -> Result<(), Error>
Sets the value associated to key
in the userdata, assuming it has __newindex
metamethod.
sourcefn call<A, R>(&self, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
fn call<A, R>(&self, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
Calls the userdata as a function assuming it has __call
metamethod.
The metamethod is called with the userdata as its first argument, followed by the passed arguments.
sourcefn call_method<A, R>(&self, name: &str, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
Calls the userdata method, assuming it has __index
metamethod
and a function associated to name
.
sourcefn call_function<A, R>(&self, name: &str, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R, Error>where
A: IntoLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
Gets the function associated to key
from the table and executes it,
passing args
as function arguments.
This is a shortcut for
table.get::<_, Function>(key)?.call(args)
This might invoke the __index
metamethod.
Object Safety§
This trait is not object safe.