pub trait LuaTableExt<'lua> {
// Required methods
fn call<A, R>(&self, args: A) -> Result<R, Error>
where A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
fn call_async<'fut, A, R>(
&self,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
where 'lua: 'fut,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua> + 'fut;
fn call_method<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
where K: ToLua<'lua>,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
fn call_function<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
where K: ToLua<'lua>,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>;
fn call_async_method<'fut, K, A, R>(
&self,
key: K,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
where 'lua: 'fut,
K: ToLua<'lua>,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua> + 'fut;
fn call_async_function<'fut, K, A, R>(
&self,
key: K,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
where 'lua: 'fut,
K: ToLua<'lua>,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua> + 'fut;
}
Expand description
An extension trait for Table
s that provides a variety of convenient functionality.
Required Methods§
Sourcefn call<A, R>(&self, args: A) -> Result<R, Error>where
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
fn call<A, R>(&self, args: A) -> Result<R, Error>where
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
Calls the table as function assuming it has __call
metamethod.
The metamethod is called with the table as its first argument, followed by the passed arguments.
Sourcefn call_async<'fut, A, R>(
&self,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>where
'lua: 'fut,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua> + 'fut,
fn call_async<'fut, A, R>(
&self,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>where
'lua: 'fut,
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua> + 'fut,
Asynchronously calls the table as function assuming it has __call
metamethod.
The metamethod is called with the table as its first argument, followed by the passed arguments.
Sourcefn call_method<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
fn call_method<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
Gets the function associated to key
from the table and executes it,
passing the table itself along with args
as function arguments.
This is a shortcut for
table.get::<_, Function>(key)?.call((table.clone(), arg1, ..., argN))
This might invoke the __index
metamethod.
Sourcefn call_function<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
fn call_function<K, A, R>(&self, key: K, args: A) -> Result<R, Error>
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_method<'fut, K, A, R>(
&self,
key: K,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
fn call_async_method<'fut, K, A, R>( &self, key: K, args: A, ) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
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_async_function<'fut, K, A, R>(
&self,
key: K,
args: A,
) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
fn call_async_function<'fut, K, A, R>( &self, key: K, args: A, ) -> Pin<Box<dyn Future<Output = Result<R, Error>> + 'fut>>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.