pub trait Index<L>: AsRef<Object<L>>where
L: AsLua,{
// Provided methods
fn get<'lua, K, R>(&'lua self, key: K) -> Option<R>
where L: 'lua,
K: PushOneInto<LuaState>,
K::Err: Into<Void>,
R: LuaRead<PushGuard<&'lua L>> { ... }
fn try_get<'lua, K, R>(&'lua self, key: K) -> Result<R, LuaError>
where L: 'lua,
K: PushOneInto<LuaState>,
K::Err: Into<Void>,
R: LuaRead<PushGuard<&'lua L>> { ... }
fn into_get<K, R>(self, key: K) -> Result<R, Self>
where Self: AsLua + Sized,
K: PushOneInto<LuaState>,
K::Err: Into<Void>,
R: LuaRead<PushGuard<Self>> { ... }
fn try_into_get<K, R>(self, key: K) -> Result<R, (Self, LuaError)>
where Self: AsLua + Sized,
K: PushOneInto<LuaState>,
K::Err: Into<Void>,
R: LuaRead<PushGuard<Self>> { ... }
fn call_method<'lua, A, R>(
&'lua self,
name: &str,
args: A,
) -> Result<R, MethodCallError<A::Err>>
where L: 'lua,
Self: Push<LuaState>,
Self::Err: Into<Void>,
A: PushInto<LuaState>,
R: LuaRead<PushGuard<Callable<PushGuard<&'lua L>>>> { ... }
}Expand description
Types implementing this trait represent a single lua value that can be
indexed, i.e. a regular lua table or other value implementing __index
metamethod.
Provided Methods§
Sourcefn get<'lua, K, R>(&'lua self, key: K) -> Option<R>
fn get<'lua, K, R>(&'lua self, key: K) -> Option<R>
Loads a value from the table (or other object using the __index
metamethod) given its index.
The index must implement the PushOneInto trait and the return type
must implement the LuaRead trait. See the documentation at the
crate root for more information.
Sourcefn try_get<'lua, K, R>(&'lua self, key: K) -> Result<R, LuaError>
fn try_get<'lua, K, R>(&'lua self, key: K) -> Result<R, LuaError>
Loads a value from the table (or other object using the __index
metamethod) given its index.
§Possible errors:
LuaError::ExecutionErrorif an error happened during the check thatindexis valid inselfLuaError::WrongTypeif the result lua value couldn’t be read as the expected rust type
The index must implement the PushOneInto trait and the return type
must implement the LuaRead trait. See the documentation at the
crate root for more information.
Sourcefn into_get<K, R>(self, key: K) -> Result<R, Self>
fn into_get<K, R>(self, key: K) -> Result<R, Self>
Loads a value in the table (or other object using the __index
metamethod) given its index, with the result capturing the table by
value.
See also Index::get
Sourcefn try_into_get<K, R>(self, key: K) -> Result<R, (Self, LuaError)>
fn try_into_get<K, R>(self, key: K) -> Result<R, (Self, LuaError)>
Loads a value in the table (or other object using the __index
metamethod) given its index, with the result capturing the table by
value.
§Possible errors:
LuaError::ExecutionErrorif an error happened during the check thatindexis valid inselfLuaError::WrongTypeif the result lua value couldn’t be read as the expected rust type
See also Index::get
Sourcefn call_method<'lua, A, R>(
&'lua self,
name: &str,
args: A,
) -> Result<R, MethodCallError<A::Err>>
fn call_method<'lua, A, R>( &'lua self, name: &str, args: A, ) -> Result<R, MethodCallError<A::Err>>
Calls the method called name of the table (or other indexable object)
with the provided args.
Possible errors:
MethodCallError::NoSuchMethodin caseself[name]isnilMethodCallError::PushErrorif pushingargsfailedMethodCallError::LuaErrorif error happened during the function call
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.