Struct tlua::PushGuard

source ·
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>

source

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.

source

pub fn assert_one_and_forget(self) -> i32

source

pub fn size(&self) -> i32

Returns the number of elements managed by this PushGuard.

source

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.

source

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,

source§

fn as_lua(&self) -> *mut lua_State

source§

fn try_push<T>( self, v: T ) -> Result<PushGuard<Self>, (<T as PushInto<Self>>::Err, Self)>
where Self: Sized, T: PushInto<Self>,

Try to push v onto the lua stack. Read more
source§

fn push<T>(self, v: T) -> PushGuard<Self>
where Self: Sized, T: PushInto<Self>, <T as PushInto<Self>>::Err: Into<Void>,

Push v onto the lua stack. Read more
source§

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. Read more
source§

fn push_one<T>(self, v: T) -> PushGuard<Self>
where Self: Sized, T: PushOneInto<Self>, <T as PushInto<Self>>::Err: Into<Void>,

Push v onto the lua stack. Read more
source§

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>,

Push iterator onto the lua stack as a lua table. Read more
source§

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>,

Push iterator onto the lua stack as a lua table. Read more
source§

fn read<T>(self) -> ReadResult<T, Self>
where Self: Sized, T: LuaRead<Self>,

source§

fn read_at<T>(self, index: i32) -> ReadResult<T, Self>
where Self: Sized, T: LuaRead<Self>,

source§

fn read_at_nz<T>(self, index: NonZeroI32) -> ReadResult<T, Self>
where Self: Sized, T: LuaRead<Self>,

source§

fn pcall<F, R>(&self, f: F) -> Result<R, LuaError>
where F: FnOnce(StaticLua) -> R,

Call a rust function in protected mode. If a lua error is thrown during execution of f the function will return a LuaError. Read more
source§

impl<L> Debug for PushGuard<L>
where L: AsLua + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<L: AsLua> Drop for PushGuard<L>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<L> RefUnwindSafe for PushGuard<L>
where L: RefUnwindSafe,

§

impl<L> Send for PushGuard<L>
where L: Send,

§

impl<L> Sync for PushGuard<L>
where L: Sync,

§

impl<L> Unpin for PushGuard<L>
where L: Unpin,

§

impl<L> UnwindSafe for PushGuard<L>
where L: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.