[−][src]Struct actix_lua::dev::rlua::prelude::LuaFunction
Handle to an internal Lua function.
Methods
impl<'lua> Function<'lua>
[src]
pub fn call<A, R>(&self, args: A) -> Result<R, Error> where
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
[src]
A: ToLuaMulti<'lua>,
R: FromLuaMulti<'lua>,
Calls the function, passing args
as function arguments.
The function's return values are converted to the generic type R
.
Examples
Call Lua's built-in tostring
function:
let globals = lua_context.globals(); let tostring: Function = globals.get("tostring")?; assert_eq!(tostring.call::<_, String>(123)?, "123");
Call a function with multiple arguments:
let sum: Function = lua_context.load( r#" function(a, b) return a + b end "#).eval()?; assert_eq!(sum.call::<_, u32>((3, 4))?, 3 + 4);
pub fn bind<A>(&self, args: A) -> Result<Function<'lua>, Error> where
A: ToLuaMulti<'lua>,
[src]
A: ToLuaMulti<'lua>,
Returns a function that, when called, calls self
, passing args
as the first set of
arguments.
If any arguments are passed to the returned function, they will be passed after args
.
Examples
let sum: Function = lua_context.load(r#" function(a, b) return a + b end "#).eval()?; let bound_a = sum.bind(1)?; assert_eq!(bound_a.call::<_, u32>(2)?, 1 + 2); let bound_a_and_b = sum.bind(13)?.bind(57)?; assert_eq!(bound_a_and_b.call::<_, u32>(())?, 13 + 57);
Trait Implementations
impl<'lua> ToLua<'lua> for Function<'lua>
[src]
impl<'lua> FromLua<'lua> for Function<'lua>
[src]
impl<'lua> Debug for Function<'lua>
[src]
impl<'lua> Clone for Function<'lua>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<'lua, T> FromLua for T where
T: 'static + UserData + Clone,
[src]
T: 'static + UserData + Clone,
impl<'lua, T> ToLuaMulti for T where
T: ToLua<'lua>,
[src]
T: ToLua<'lua>,
fn to_lua_multi(self, lua: Context<'lua>) -> Result<MultiValue<'lua>, Error>
[src]
impl<'lua, T> FromLuaMulti for T where
T: FromLua<'lua>,
[src]
T: FromLua<'lua>,
fn from_lua_multi(
values: MultiValue<'lua>,
lua: Context<'lua>
) -> Result<T, Error>
[src]
values: MultiValue<'lua>,
lua: Context<'lua>
) -> Result<T, Error>
impl<'lua, T> ToLua for T where
T: 'static + UserData + Send,
[src]
T: 'static + UserData + Send,