Struct luaext::context::Context
[−]
[src]
pub struct Context<'a> { /* fields omitted */ }
A wrapper around a Lua State.
Contains its own section of a Lua Stack; when the context goes out of scope, any value pushed using this context is popped.
Methods
impl<'a> Context<'a>
[src]
fn new(state: &mut State) -> Context
Creates a new Context using an existing state.
fn get_state(&mut self) -> &mut State
Get this context's contained state.
fn push_number(&mut self, value: f64) -> LuaNumber
Push a floating point number onto the stack.
fn push_string(&mut self, value: &str) -> LuaString
Push a string onto the stack.
fn push_table(&mut self) -> LuaTable
Create a new table and push it into the stack.
fn push_bool(&mut self, value: bool) -> LuaBool
Push a boolean value onto the stack.
fn push_function(&mut self, func: Function) -> LuaFunction
Push a C function onto the stack.
fn push_integer(&mut self, value: i64) -> LuaInteger
Push an integer onto the stack.
fn push_nil(&mut self) -> LuaNil
Push a nil value onto the stack.
fn push_userdata<T>(&mut self, value: T) -> LuaUserdata
Push a user-defined value onto the stack.
fn push_userdata_named<T>(&mut self, value: T, name: &str) -> LuaUserdata
Push a user-defined value onto the stack, and give it the metatable named 'name.'
fn push_thread(&mut self) -> LuaThread
Push a Lua thread onto the stack
You will need to do stuff with the Lua thread in a separate thread if you want two Lua threads to run concurrently, Lua doesn't do any actual multithreading itself.
fn create_lib(&mut self, lib: &[(&str, Function)]) -> LuaTable
Create a library using an array of Functions, and push the library table onto the stack.,
fn push_global(&mut self, key: &str) -> LuaGeneric
Push a global value onto the stack.
fn set_global(&mut self, key: &str, value: &ToLua)
Set a value in the global Lua namespace.
fn get_from_registry(&mut self, key: &ToLua) -> LuaGeneric
Get a value from the Lua registry.
fn get_from_registry_typed<T: FromLua>(&mut self, key: &ToLua) -> Option<T>
Get a value from the Lua registry using a type.
fn set_in_registry(&mut self, key: &ToLua, value: &ToLua)
Set a value in the Lua registry.
fn get_arg(&mut self, arg: Index) -> Option<LuaGeneric>
Get an argument from this context.
fn get_arg_typed<T: FromLua>(&mut self, arg: Index) -> Option<T>
Get an argument from this context.
fn get_arg_typed_or<T: FromLua>(&mut self, arg: Index, value: T) -> Option<T>
Get an argument from this context.
If the argument does not exist, return a default value.
fn do_string(&mut self, s: &str) -> Result<()>
Execute valid Lua code.
Errors
Returns an error if the string is not valid Lua, or a runtime error occurs during execution.
fn push_context(&mut self) -> Context
Push a new context on top of the current context.
New values can not be pushed onto the old context until the new context goes out of scope; however, values pushed by the old context can still be used by the new context.
fn return_context(self, args: &[&ToLua]) -> Index
Returns a list of values to Lua.
fn metatable_register(&mut self, name: &str) -> (bool, LuaTable)
Register a new metatable in the registry.
Returns a tuple; the first value is if this metatable should be initialized, and the second value is the metatable itself.
fn metatable_get(&mut self, name: &str) -> Option<LuaTable>
Get a metatable from the registry.
fn metatable_register_named<T>(
&mut self,
lib: &[(&str, Function)],
metamethods: &[(&str, Function)],
unique_name: &str
) -> Option<LuaTable>
&mut self,
lib: &[(&str, Function)],
metamethods: &[(&str, Function)],
unique_name: &str
) -> Option<LuaTable>
Register a named metatable into the Lua registry.
Takes a list of member functions, a list of metamethods, and a unique name for this metatable.