Struct lua::State [] [src]

pub struct State { /* fields omitted */ }

An idiomatic, Rust wrapper around lua_State.

Function names adhere to Rust naming conventions. Most of the time, this means breaking up long C function names using underscores; however, there are some cases where different names are used. Typically, these are cases where the name itself is a reserved Rust keyword (such as ref in luaL_ref or where in luaL_where) or where the name is used in both the base Lua library and the auxiliary Lua library (such as lua_getmetatable and luaL_getmetatable). More descriptive names have been chosen for these functions. Finally, any reference to C functions has been replaced by the term native functions. lua_iscfunction is is_native_fn and lua_tocfunction is to_native_fn.

Methods

impl State
[src]

Initializes a new Lua state. This function does not open any libraries by default. Calls lua_newstate internally.

Constructs a wrapper State from a raw pointer. This is suitable for use inside of native functions that accept a lua_State to obtain a wrapper.

Returns an unsafe pointer to the wrapped lua_State.

Maps to luaL_openlibs.

Preloads library, i.e. it's not exposed, but can be required

Loads a built-in library and exposes it into lua code

Maps to luaopen_base.

Maps to luaopen_coroutine.

Maps to luaopen_table.

Maps to luaopen_io.

Maps to luaopen_os.

Maps to luaopen_string.

Maps to luaopen_utf8.

Maps to luaopen_bit32.

Maps to luaopen_math.

Maps to luaopen_debug.

Maps to luaopen_package.

Maps to luaL_dofile.

Maps to luaL_dostring.

Pushes the given value onto the stack.

Converts the value on top of the stack to a value of type T and returns it.

Maps to lua_close.

Maps to lua_newthread.

Maps to lua_atpanic.

Maps to lua_version.

Maps to lua_absindex.

Maps to lua_gettop.

Maps to lua_settop.

Maps to lua_pushvalue.

Maps to lua_rotate.

Maps to lua_copy.

Maps to lua_checkstack.

Maps to lua_xmove.

Maps to lua_isnumber.

Maps to lua_isstring.

Maps to lua_iscfunction.

Maps to lua_isinteger.

Maps to lua_isuserdata.

Maps to lua_type.

Maps to lua_typename.

Maps to lua_tonumberx.

Maps to lua_tointegerx.

Maps to lua_toboolean.

Maps to lua_rawlen.

Maps to lua_tocfunction.

Maps to lua_touserdata.

Convenience function that calls to_userdata and performs a cast.

Maps to lua_tothread.

Maps to lua_topointer.

Maps to lua_arith.

Maps to lua_rawequal.

Maps to lua_compare.

Maps to lua_pushnil.

Maps to lua_pushnumber.

Maps to lua_pushinteger.

Maps to lua_pushlstring.

Maps to lua_pushcclosure.

Maps to lua_pushboolean.

Maps to lua_pushlightuserdata. The Lua state will receive a pointer to the given value. The caller is responsible for cleaning up the data. Any code that manipulates the userdata is free to modify its contents, so memory safety is not guaranteed.

Maps to lua_pushthread.

Maps to lua_getglobal.

Maps to lua_gettable.

Maps to lua_getfield.

Maps to lua_geti.

Maps to lua_rawget.

Maps to lua_rawgeti.

Maps to lua_rawgetp.

Maps to lua_createtable.

Maps to lua_newuserdata. The pointer returned is owned by the Lua state and it will be garbage collected when it is no longer in use or the state is closed. To specify custom cleanup behavior, use a __gc metamethod.

Convenience function that uses type information to call new_userdata and perform a cast.

Example

unsafe { *state.new_userdata_typed() = MyStruct::new(...); }
state.set_metatable_from_registry("MyStruct");

Maps to lua_getmetatable.

Maps to lua_getuservalue.

Maps to lua_setglobal.

Maps to lua_settable.

Maps to lua_setfield.

Maps to lua_seti.

Maps to lua_rawset.

Maps to lua_rawseti.

Maps to lua_rawsetp.

Maps to lua_setmetatable.

Maps to lua_setuservalue.

Maps to lua_callk.

Maps to lua_call.

Maps to lua_pcallk.

Maps to lua_pcall.

Maps to lua_load.

Maps to lua_dump.

Maps to lua_yieldk.

Maps to lua_yield. This function is not called yield because it is a reserved keyword.

Maps to lua_resume.

Maps to lua_status.

Maps to lua_isyieldable.

Maps to lua_gc.

Maps to lua_error.

Maps to lua_next.

Maps to lua_concat.

Maps to lua_len.

Maps to lua_stringtonumber.

Maps to lua_getallocf.

Maps to lua_setallocf.

Set extra data. Return previous value if it was set.

Do some actions with mutable extra.

Unwrap and downcast extra to typed.

Panics

Panics if state has no attached Extra or it's impossible to downcast to T.

Maps to lua_tonumber.

Maps to lua_tointeger.

Maps to lua_pop.

Maps to lua_newtable.

Maps to lua_register.

Maps to lua_pushcfunction.

Maps to lua_isfunction.

Maps to lua_istable.

Maps to lua_islightuserdata.

Maps to lua_isnil.

Maps to lua_isboolean.

Maps to lua_isthread.

Maps to lua_isnone.

Maps to lua_isnoneornil.

Maps to lua_pushglobaltable.

Maps to lua_insert.

Maps to lua_remove.

Maps to lua_replace.

Maps to lua_getstack.

Maps to lua_getinfo.

Maps to lua_getlocal.

Maps to lua_setlocal.

Maps to lua_getupvalue.

Maps to lua_setupvalue.

Maps to lua_upvalueid.

Maps to lua_upvaluejoin.

Maps to lua_sethook.

Maps to lua_gethook.

Maps to lua_gethookmask.

Maps to lua_gethookcount.

Maps to luaL_checkversion.

Maps to luaL_getmetafield.

Maps to luaL_callmeta.

Maps to luaL_tolstring. This function is not called to_string because that method name is used for the ToString trait. This function returns a reference to the string at the given index, on which to_owned may be called.

Maps to lua_tolstring. This function is not called to_string because that method name is used for the ToString trait. This function returns a reference to the string at the given index, on which to_owned may be called.

Maps to luaL_argerror.

Maps to luaL_checknumber.

Maps to luaL_optnumber.

Maps to luaL_checkinteger.

Maps to luaL_optinteger.

Maps to luaL_checkstack.

Maps to luaL_checktype.

Maps to luaL_checkany.

Maps to luaL_newmetatable.

Maps to luaL_setmetatable.

Maps to luaL_testudata.

Convenience function that calls test_userdata and performs a cast.

Maps to luaL_checkudata.

Convenience function that calls check_userdata and performs a cast.

Maps to luaL_where. where is a reserved keyword.

Maps to luaL_checkoption.

Maps to luaL_fileresult.

Maps to luaL_execresult.

Maps to luaL_ref.

Maps to luaL_unref.

Maps to luaL_loadfilex.

Maps to luaL_loadfile.

Maps to luaL_loadbufferx.

Maps to luaL_loadstring.

Maps to luaL_len.

Maps to luaL_gsub.

Maps to luaL_setfuncs.

Maps to luaL_getsubtable.

Maps to luaL_traceback.

Maps to luaL_requiref.

Maps to luaL_newlibtable.

Maps to luaL_newlib.

Maps to luaL_argcheck.

Maps to luaL_checklstring.

Maps to luaL_optlstring.

Maps to luaL_typename.

Maps to luaL_getmetatable.

Maps to luaL_loadbuffer.

Trait Implementations

impl Send for State
[src]

impl Drop for State
[src]

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