pub trait AsLua {
// Required method
fn as_lua(&self) -> *mut lua_State;
// Provided methods
fn try_push<T>(
self,
v: T,
) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>
where Self: Sized,
T: PushInto<Self> { ... }
fn push<T>(self, v: T) -> PushGuard<Self>
where Self: Sized,
T: PushInto<Self>,
<T as PushInto<Self>>::Err: Into<Void> { ... }
fn try_push_one<T>(
self,
v: T,
) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>
where Self: Sized,
T: PushOneInto<Self> { ... }
fn push_one<T>(self, v: T) -> PushGuard<Self>
where Self: Sized,
T: PushOneInto<Self>,
<T as PushInto<Self>>::Err: Into<Void> { ... }
fn push_iter<I>(self, iterator: I) -> Result<PushGuard<Self>, Self>
where Self: Sized,
I: Iterator,
<I as Iterator>::Item: PushInto<LuaState>,
<<I as Iterator>::Item as PushInto<LuaState>>::Err: Into<Void> { ... }
fn try_push_iter<I>(
self,
iterator: I,
) -> Result<PushGuard<Self>, (PushIterErrorOf<I>, Self)>
where Self: Sized,
I: Iterator,
<I as Iterator>::Item: PushInto<LuaState> { ... }
fn read<T>(self) -> ReadResult<T, Self>
where Self: Sized,
T: LuaRead<Self> { ... }
fn read_at<T>(self, index: i32) -> ReadResult<T, Self>
where Self: Sized,
T: LuaRead<Self> { ... }
fn read_at_nz<T>(self, index: NonZeroI32) -> ReadResult<T, Self>
where Self: Sized,
T: LuaRead<Self> { ... }
fn pcall<F, R>(&self, f: F) -> Result<R, LuaError>
where F: FnOnce(StaticLua) -> R { ... }
}
Expand description
Trait for objects that have access to a Lua context.
Required Methods§
Provided Methods§
Sourcefn try_push<T>(
self,
v: T,
) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>
fn try_push<T>( self, v: T, ) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>
Try to push v
onto the lua stack.
In case of success returns a PushGuard
which captures self
by value
and stores the amount of values pushed onto the stack.
In case of failure returns a tuple with 2 elements:
- an error, which occured during the attempt to push
self
Sourcefn push<T>(self, v: T) -> PushGuard<Self>
fn push<T>(self, v: T) -> PushGuard<Self>
Push v
onto the lua stack.
This method is only available if T::Err
implements Into<Void>
, which
means that no error can happen during the attempt to push.
Returns a PushGuard
which captures self
by value and stores the
amount of values pushed onto the stack.
Sourcefn try_push_one<T>(
self,
v: T,
) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>where
Self: Sized,
T: PushOneInto<Self>,
fn try_push_one<T>(
self,
v: T,
) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>where
Self: Sized,
T: PushOneInto<Self>,
Try to push v
onto the lua stack.
This method is only available if T
implements PushOneInto
, which
means that it pushes a single value onto the stack.
Returns a PushGuard
which captures self
by value and stores the
amount of values pushed onto the stack (ideally this will be 1, but it
is the responsibility of the impelemntor to make sure it is so).
Sourcefn push_one<T>(self, v: T) -> PushGuard<Self>
fn push_one<T>(self, v: T) -> PushGuard<Self>
Push v
onto the lua stack.
This method is only available if
T
implementsPushOneInto
, which means that it pushes a single value onto the stackT::Err
implementsInto<Void>
, which means that no error can happen during the attempt to push
Returns a PushGuard
which captures self
by value and stores the
amount of values pushed onto the stack (ideally this will be 1, but it
is the responsibility of the impelemntor to make sure it is so).
Sourcefn push_iter<I>(self, iterator: I) -> Result<PushGuard<Self>, Self>
fn push_iter<I>(self, iterator: I) -> Result<PushGuard<Self>, Self>
Push iterator
onto the lua stack as a lua table.
This method is only available if
I::Item
implementsPushInto<LuaState>
, which means that it can be pushed onto the lua stack by valueI::Item::Err
implementsInto<Void>
, which means that no error can happen during the attempt to push
If I::Item
pushes a single value onto the stack, the resulting lua
table is a lua sequence (a table with 1-based integer keys).
If I::Item
pushes 2 values onto the stack, the resulting lua table is
a regular lua table with the provided keys.
If I::Item
pushes more than 2 values, the function returns Err(self)
.
Returns a PushGuard
which captures self
by value and stores the
amount of values pushed onto the stack (exactly 1 – lua table).
Sourcefn try_push_iter<I>(
self,
iterator: I,
) -> Result<PushGuard<Self>, (PushIterErrorOf<I>, Self)>
fn try_push_iter<I>( self, iterator: I, ) -> Result<PushGuard<Self>, (PushIterErrorOf<I>, Self)>
Push iterator
onto the lua stack as a lua table.
This method is only available if I::Item
implements
PushInto<LuaState>
, which means that it can be pushed onto the lua
stack by value.
If I::Item
pushes a single value onto the stack, the resulting lua
table is a lua sequence (a table with 1-based integer keys).
If I::Item
pushes 2 values onto the stack, the resulting lua table is
a regular lua table with the provided keys.
If I::Item
pushes more than 2 values or an error happens during an
attempt to push, the function returns Err((e, self))
where e
is a
PushIterErrorOf
.
Returns a PushGuard
which captures self
by value and stores the
amount of values pushed onto the stack (exactly 1 – lua table).
fn read<T>(self) -> ReadResult<T, Self>
fn read_at<T>(self, index: i32) -> ReadResult<T, Self>
fn read_at_nz<T>(self, index: NonZeroI32) -> ReadResult<T, Self>
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.