Trait mlua::AnyUserDataExt
source · pub trait AnyUserDataExt: Sealed {
// Required methods
fn get<K: IntoLua, V: FromLua>(&self, key: K) -> Result<V>;
fn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()>;
fn call<A, R>(&self, args: A) -> Result<R>
where A: IntoLuaMulti,
R: FromLuaMulti;
fn call_async<A, R>(&self, args: A) -> impl Future<Output = Result<R>>
where A: IntoLuaMulti,
R: FromLuaMulti;
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>
where A: IntoLuaMulti,
R: FromLuaMulti;
fn call_async_method<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>
where A: IntoLuaMulti,
R: FromLuaMulti;
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>
where A: IntoLuaMulti,
R: FromLuaMulti;
fn call_async_function<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>
where A: IntoLuaMulti,
R: FromLuaMulti;
}Expand description
An extension trait for AnyUserData that provides a variety of convenient functionality.
Required Methods§
sourcefn get<K: IntoLua, V: FromLua>(&self, key: K) -> Result<V>
fn get<K: IntoLua, V: FromLua>(&self, key: K) -> Result<V>
Gets the value associated to key from the userdata, assuming it has __index metamethod.
sourcefn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()>
fn set<K: IntoLua, V: IntoLua>(&self, key: K, value: V) -> Result<()>
Sets the value associated to key in the userdata, assuming it has __newindex metamethod.
sourcefn call<A, R>(&self, args: A) -> Result<R>where
A: IntoLuaMulti,
R: FromLuaMulti,
fn call<A, R>(&self, args: A) -> Result<R>where
A: IntoLuaMulti,
R: FromLuaMulti,
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_async<A, R>(&self, args: A) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
Available on crate feature async only.
fn call_async<A, R>(&self, args: A) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
async only.Asynchronously 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>where
A: IntoLuaMulti,
R: FromLuaMulti,
fn call_method<A, R>(&self, name: &str, args: A) -> Result<R>where
A: IntoLuaMulti,
R: FromLuaMulti,
Calls the userdata method, assuming it has __index metamethod
and a function associated to name.
sourcefn call_async_method<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
Available on crate feature async only.
fn call_async_method<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
async only.Gets the function associated to key from the table and asynchronously executes it,
passing the table itself along with args as function arguments and returning Future.
Requires feature = "async"
This might invoke the __index metamethod.
sourcefn call_function<A, R>(&self, name: &str, args: A) -> Result<R>where
A: IntoLuaMulti,
R: FromLuaMulti,
fn call_function<A, R>(&self, name: &str, args: A) -> Result<R>where
A: IntoLuaMulti,
R: FromLuaMulti,
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.
sourcefn call_async_function<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
Available on crate feature async only.
fn call_async_function<A, R>(
&self,
name: &str,
args: A,
) -> impl Future<Output = Result<R>>where
A: IntoLuaMulti,
R: FromLuaMulti,
async only.Gets the function associated to key from the table and asynchronously executes it,
passing args as function arguments and returning Future.
Requires feature = "async"
This might invoke the __index metamethod.