Struct TypedFunction

Source
pub struct TypedFunction<'lua, Params, Response>
where Params: TypedMultiValue, Response: TypedMultiValue,
{ /* private fields */ }
Expand description

Helper to bake the type information for a lua Function. This makes repeated calls to the Function’s call all the same with enforced arguments and return types.

Implementations§

Source§

impl<'lua, Params, Response> TypedFunction<'lua, Params, Response>
where Params: TypedMultiValue + IntoLuaMulti<'lua>, Response: TypedMultiValue + FromLuaMulti<'lua>,

Source

pub fn call(&self, params: Params) -> Result<Response>

Same as Function::call but with the param and return types already specified

Source

pub unsafe fn call_unsafe(&self, params: Params) -> Response

Same as Function::call but with the param and return types already specified

§Safety

Panics if any lua errors occur

Source

pub fn from_rust<F>(&self, lua: &'lua Lua, func: F) -> Result<Self>
where Params: TypedMultiValue + FromLuaMulti<'lua>, Response: TypedMultiValue + IntoLuaMulti<'lua>, F: Fn(&'lua Lua, Params) -> Result<Response> + MaybeSend + 'static,

Create a typed function from a rust function.

This will call Lua::create_function under the hood

Trait Implementations§

Source§

impl<'lua, Params, Response> FromLua<'lua> for TypedFunction<'lua, Params, Response>
where Params: TypedMultiValue, Response: TypedMultiValue,

Source§

fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> LuaResult<Self>

Performs the conversion.
Source§

impl<'lua, Params, Response> IntoLua<'lua> for TypedFunction<'lua, Params, Response>
where Params: TypedMultiValue, Response: TypedMultiValue,

Source§

fn into_lua(self, _lua: &'lua Lua) -> LuaResult<Value<'lua>>

Performs the conversion.
Source§

impl<'lua, Params, Response> Typed for TypedFunction<'lua, Params, Response>
where Params: TypedMultiValue, Response: TypedMultiValue,

Source§

fn ty() -> Type

Get the type representation
Source§

fn as_param() -> Param

Get the type as a function parameter

Auto Trait Implementations§

§

impl<'lua, Params, Response> Freeze for TypedFunction<'lua, Params, Response>

§

impl<'lua, Params, Response> !RefUnwindSafe for TypedFunction<'lua, Params, Response>

§

impl<'lua, Params, Response> !Send for TypedFunction<'lua, Params, Response>

§

impl<'lua, Params, Response> !Sync for TypedFunction<'lua, Params, Response>

§

impl<'lua, Params, Response> Unpin for TypedFunction<'lua, Params, Response>
where Params: Unpin, Response: Unpin,

§

impl<'lua, Params, Response> !UnwindSafe for TypedFunction<'lua, Params, Response>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'lua, T> FromLuaMulti<'lua> for T
where T: FromLua<'lua>,

Source§

fn from_lua_multi(values: MultiValue<'lua>, lua: &'lua Lua) -> Result<T, Error>

Performs the conversion. Read more
Source§

fn from_lua_args( args: MultiValue<'lua>, i: usize, to: Option<&str>, lua: &'lua Lua, ) -> Result<T, Error>

Source§

unsafe fn from_stack_multi(nvals: i32, lua: &'lua Lua) -> Result<T, Error>

Source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &'lua Lua, ) -> Result<T, Error>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'lua, T> IntoLuaMulti<'lua> for T
where T: IntoLua<'lua>,

Source§

fn into_lua_multi(self, lua: &'lua Lua) -> Result<MultiValue<'lua>, Error>

Performs the conversion.
Source§

unsafe fn push_into_stack_multi(self, lua: &'lua Lua) -> Result<i32, Error>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<A> TypedMultiValue for A
where A: Typed,

Source§

fn get_types_as_params() -> Vec<Param>

Gets the type representations as used for function parameters
Source§

fn get_types() -> Vec<Type>

Gets the types contained in this collection. Order IS important.
Source§

fn get_types_as_returns() -> Vec<Return>