Struct luaext::types::function::LuaFunction [] [src]

pub struct LuaFunction { /* fields omitted */ }

Reperesents a callable function on the Lua stack

Functions that can be called may be defined in Lua, Rust, C, or any other language with Lua bindings.

Examples

context.do_string("function double(x) return x * 2 end").unwrap();
let lua_double: LuaFunction = context.push_global("double")
    .get_value(&mut context).unwrap();
let result = lua_double.call_singleret(&mut context, &[&4])
    .and_then(|v| v.get_value(&mut context));
assert_eq!(result, Some(8));

Methods

impl LuaFunction
[src]

Create a new LuaFunction given an index

Protected function call, errors return an Err If the function call is successful, returns a list of all return values (with a maximum size nresults)

Errors

Returns an Error if Lua encounters a runtime error while running this function. If an errfunc is given, then the given function will be called with the error message as an argument, and the function should return a new error message. errfunc will not be called if no error was encountered, the error that occured was an out of memeory error, or if another error occurred while running errfunc.

Same as pcall, but returns all return values

Same as pcall, but only returns at most one return value.

Same as pcall, but returns nothing.

Call this function, returns a list of return values (with a maximum size nresults).

Panics

This function will panic if Lua encounters a runtime error. It's not really a panic, it's actually a longjmp, but it might as well be a panic.

Same as call, but returns at most one return value.

Same as call, but returns all return values.

Same as call, but does not return any return values.

Trait Implementations

impl LuaStackable for LuaFunction
[src]

Get the position of this value on the stack

impl ToLua for LuaFunction
[src]

Pushes a value of type Self onto the stack of a Lua state.

impl FromLua for LuaFunction
[src]

Converts the value on top of the stack of a Lua state to a value of type Option<Self>. Read more