LuaModule

Struct LuaModule 

Source
pub struct LuaModule<'a, 'b> { /* private fields */ }
Expand description

(Sub-)module in a LuaMachine (which is a Lua table)

The type LuaModule is used to implement the abstract Module trait which allows getting and setting variables (through Module::get and Module::set, respectively) a module (in this case: in a Lua table). A LuaModule may be obtained by calling HasModules::module on the LuaMachine (to obtain a top-level module/table) or Module::module on a LuaModule (to obtain a sub module/table, respectively).

To set global variables, use Globals::get and Globals::set directly on the LuaMachine instead.

§Lifetimes

Lifetime argument 'a corresponds to the lifetime argument 'a of LuaMachine. It is a lower bound for closures passed to the Lua machine.

Lifetime argument 'b corresponds to the lifetime of the shared reference to the LuaMachine being worked with.

Trait Implementations§

Source§

impl<'a, 'b> Module<'a, 'b> for LuaModule<'a, 'b>

Source§

fn module(&self, name: &str) -> Result<Self, MachineError>

Open a sub-module (create if non-existent)

Source§

fn get( &self, name: &str, ) -> Result<<Self::Machine as Machine<'a>>::Datum<'b, 'static>, MachineError>

Get value from module

Source§

fn set<'c>( &self, name: &str, datum: <Self::Machine as Machine<'a>>::Datum<'b, 'c>, ) -> Result<(), MachineError>

Set value in module

Source§

type Machine = LuaMachine<'a>

Machine type which the module belongs to

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for LuaModule<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for LuaModule<'a, 'b>

§

impl<'a, 'b> !Send for LuaModule<'a, 'b>

§

impl<'a, 'b> !Sync for LuaModule<'a, 'b>

§

impl<'a, 'b> Unpin for LuaModule<'a, 'b>

§

impl<'a, 'b> UnwindSafe for LuaModule<'a, 'b>

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

Source§

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

Source§

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.