Struct hlua::Lua [] [src]

pub struct Lua<'lua> {
    // some fields omitted
}

Main object of the library.

The lifetime parameter corresponds to the lifetime of the content of the Lua context.

Methods

impl<'lua> Lua<'lua>
[src]

fn new() -> Lua<'lua>

Builds a new Lua context.

Panic

The function panics if the underlying call to lua_newstate fails (which indicates lack of memory).

unsafe fn from_existing_state<T>(lua: *mut T, close_at_the_end: bool) -> Lua<'lua>

Takes an existing lua_State and build a Lua object from it.

Arguments

  • close_at_the_end: if true, lua_close will be called on the lua_State on the destructor

fn openlibs(&mut self)

Opens all standard Lua libraries. This is done by calling luaL_openlibs.

fn execute<'a, T>(&'a mut self, code: &str) -> Result<T, LuaError> where T: for<'g> LuaRead<PushGuard<&'g mut PushGuard<&'a mut Lua<'lua>>>>

Executes some Lua code on the context.

fn execute_from_reader<'a, T, R>(&'a mut self, code: R) -> Result<T, LuaError> where T: for<'g> LuaRead<PushGuard<&'g mut PushGuard<&'a mut Lua<'lua>>>>, R: Read

Executes some Lua code on the context.

fn get<'l, V, I>(&'l mut self, index: I) -> Option<V> where I: Borrow<str>, V: LuaRead<PushGuard<&'l mut Lua<'lua>>>

Reads the value of a global variable.

fn into_get<V, I>(self, index: I) -> Result<V, PushGuard<Self>> where I: Borrow<str>, V: LuaRead<PushGuard<Lua<'lua>>>

Reads the value of a global, capturing the context by value.

fn set<I, V>(&mut self, index: I, value: V) where I: Borrow<str>, V: Push<&'a mut Lua<'lua>>

Modifies the value of a global variable.

fn empty_array<'a, I>(&'a mut self, index: I) -> LuaTable<PushGuard<&'a mut Lua<'lua>>> where I: Borrow<str>

Inserts an empty array, then loads it.

Trait Implementations

impl<'a, 'lua> AsLua for Lua<'lua>
[src]

fn as_lua(&self) -> LuaContext

impl<'lua> AsMutLua for Lua<'lua>
[src]

fn as_mut_lua(&mut self) -> LuaContext

impl<'lua> Drop for Lua<'lua>
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more