Skip to main content

TypedFunction

Struct TypedFunction 

Source
pub struct TypedFunction<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<Params, Response> TypedFunction<Params, Response>

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, func: F) -> Result<Self>
where Params: TypedMultiValue + FromLuaMulti, Response: TypedMultiValue + IntoLuaMulti, F: Fn(&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<Params, Response> FromLua for TypedFunction<Params, Response>
where Params: TypedMultiValue, Response: TypedMultiValue,

Source§

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

Performs the conversion.
Source§

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

Source§

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

Performs the conversion.
Source§

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

Source§

fn ty() -> Type

Get the type representation
Source§

fn implicit() -> impl IntoIterator<Item = (&'static str, Type)>

Source§

fn as_param() -> Type

Get the type as a function parameter
Source§

fn as_return() -> Type

Get the type as a function return

Auto Trait Implementations§

§

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

§

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

§

impl<Params, Response> Send for TypedFunction<Params, Response>
where Params: Send, Response: Send,

§

impl<Params, Response> Sync for TypedFunction<Params, Response>
where Params: Sync, Response: Sync,

§

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

§

impl<Params, Response> UnsafeUnpin for TypedFunction<Params, Response>

§

impl<Params, Response> !UnwindSafe for TypedFunction<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<T> FromLuaMulti for T
where T: FromLua,

Source§

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

Performs the conversion. Read more
Source§

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

Source§

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

Source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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

Performs the conversion.
Source§

unsafe fn push_into_stack_multi(self, lua: &RawLua) -> 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_as_returns() -> Vec<Return>

Source§

fn get_types() -> Vec<Type>

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

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send,