pub trait ObjectLike: Sealed {
// Required methods
fn get<V: FromLua>(&self, key: impl IntoLua) -> Result<V>;
fn set(&self, key: impl IntoLua, value: impl IntoLua) -> Result<()>;
fn call<R>(&self, args: impl IntoLuaMulti) -> Result<R>
where R: FromLuaMulti;
fn call_async<R>(
&self,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>
where R: FromLuaMulti;
fn call_method<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>
where R: FromLuaMulti;
fn call_async_method<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>
where R: FromLuaMulti;
fn call_function<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>
where R: FromLuaMulti;
fn call_async_function<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>
where R: FromLuaMulti;
fn to_string(&self) -> Result<StdString>;
}
Expand description
A trait for types that can be used as Lua objects (usually table and userdata).
Required Methods§
Sourcefn get<V: FromLua>(&self, key: impl IntoLua) -> Result<V>
fn get<V: FromLua>(&self, key: impl IntoLua) -> Result<V>
Gets the value associated to key
from the object, assuming it has __index
metamethod.
Sourcefn set(&self, key: impl IntoLua, value: impl IntoLua) -> Result<()>
fn set(&self, key: impl IntoLua, value: impl IntoLua) -> Result<()>
Sets the value associated to key
in the object, assuming it has __newindex
metamethod.
Sourcefn call<R>(&self, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
fn call<R>(&self, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
Calls the object as a function assuming it has __call
metamethod.
The metamethod is called with the object as its first argument, followed by the passed arguments.
Sourcefn call_async<R>(
&self,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
Available on crate feature async
only.
fn call_async<R>(
&self,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
async
only.Asynchronously calls the object as a function assuming it has __call
metamethod.
The metamethod is called with the object as its first argument, followed by the passed arguments.
Sourcefn call_method<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
fn call_method<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
Gets the function associated to key name
from the object and calls it,
passing the object itself along with args
as function arguments.
Sourcefn call_async_method<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
Available on crate feature async
only.
fn call_async_method<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
async
only.Gets the function associated to key name
from the object and asynchronously calls it,
passing the object itself along with args
as function arguments.
Requires feature = "async"
This might invoke the __index
metamethod.
Sourcefn call_function<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
fn call_function<R>(&self, name: &str, args: impl IntoLuaMulti) -> Result<R>where
R: FromLuaMulti,
Gets the function associated to key name
from the object and calls it,
passing args
as function arguments.
This might invoke the __index
metamethod.
Sourcefn call_async_function<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
Available on crate feature async
only.
fn call_async_function<R>(
&self,
name: &str,
args: impl IntoLuaMulti,
) -> impl Future<Output = Result<R>>where
R: FromLuaMulti,
async
only.Gets the function associated to key name
from the object and asynchronously calls it,
passing args
as function arguments.
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.