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::ExecutionError
if an error happened during the check thatindex
is valid inself
LuaError::WrongType
if 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::ExecutionError
if an error happened during the check thatindex
is valid inself
LuaError::WrongType
if 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::NoSuchMethod
in caseself[name]
isnil
MethodCallError::PushError
if pushingargs
failedMethodCallError::LuaError
if error happened during the function call