pub struct PushGuard<L>where
L: AsLua,{ /* private fields */ }
Expand description
RAII guard for a value pushed on the stack.
You shouldn’t have to manipulate this type directly unless you are fiddling with the library’s internals.
Implementations§
source§impl<L: AsLua> PushGuard<L>
impl<L: AsLua> PushGuard<L>
sourcepub unsafe fn new(lua: L, size: i32) -> Self
pub unsafe fn new(lua: L, size: i32) -> Self
Creates a new PushGuard
from this Lua context representing size
items on the stack.
When this PushGuard
is destroyed, size
items will be popped.
§Safety
There must be at least size
elements on the lua
stack and it must be
safe to drop them at the same time with this PushGuard
.
pub fn assert_one_and_forget(self) -> i32
sourcepub unsafe fn forget(self) -> i32
pub unsafe fn forget(self) -> i32
Prevents the value from being popped when the PushGuard
is destroyed, and returns the
number of elements on the Lua stack.
§Safety
The values on the stack will not be popped automatically, so the caller must ensure nothing is leaked.
sourcepub fn into_inner(self) -> L
pub fn into_inner(self) -> L
Destroys the guard, popping the value. Returns the inner part, which returns access when using by-value capture.
Trait Implementations§
source§impl<L> AsLua for PushGuard<L>where
L: AsLua,
impl<L> AsLua for PushGuard<L>where
L: AsLua,
fn as_lua(&self) -> *mut lua_State
source§fn 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)>
v
onto the lua stack. Read moresource§fn 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>,
v
onto the lua stack. Read moresource§fn push_iter<I>(self, iterator: I) -> Result<PushGuard<Self>, Self>
fn push_iter<I>(self, iterator: I) -> Result<PushGuard<Self>, Self>
iterator
onto the lua stack as a lua table. Read moresource§fn 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)>
iterator
onto the lua stack as a lua table. Read more