Struct mlua::UserDataRegistry

source ·
pub struct UserDataRegistry<'lua, T: 'static> { /* private fields */ }
Expand description

Handle to registry for userdata methods and metamethods.

Trait Implementations§

source§

impl<'lua, T: 'static> UserDataFields<'lua, T> for UserDataRegistry<'lua, T>

source§

fn add_field<V>(&mut self, name: impl AsRef<str>, value: V)
where V: IntoLua<'lua> + Clone + 'static,

Add a static field to the UserData. Read more
source§

fn add_field_method_get<M, R>(&mut self, name: impl AsRef<str>, method: M)
where M: Fn(&'lua Lua, &T) -> Result<R> + MaybeSend + 'static, R: IntoLua<'lua>,

Add a regular field getter as a method which accepts a &T as the parameter. Read more
source§

fn add_field_method_set<M, A>(&mut self, name: impl AsRef<str>, method: M)
where M: FnMut(&'lua Lua, &mut T, A) -> Result<()> + MaybeSend + 'static, A: FromLua<'lua>,

Add a regular field setter as a method which accepts a &mut T as the first parameter. Read more
source§

fn add_field_function_get<F, R>(&mut self, name: impl AsRef<str>, function: F)
where F: Fn(&'lua Lua, AnyUserData<'lua>) -> Result<R> + MaybeSend + 'static, R: IntoLua<'lua>,

Add a regular field getter as a function which accepts a generic AnyUserData of type T argument. Read more
source§

fn add_field_function_set<F, A>(&mut self, name: impl AsRef<str>, function: F)
where F: FnMut(&'lua Lua, AnyUserData<'lua>, A) -> Result<()> + MaybeSend + 'static, A: FromLua<'lua>,

Add a regular field setter as a function which accepts a generic AnyUserData of type T first argument. Read more
source§

fn add_meta_field<V>(&mut self, name: impl AsRef<str>, value: V)
where V: IntoLua<'lua> + Clone + 'static,

Add a metatable field. Read more
source§

fn add_meta_field_with<F, R>(&mut self, name: impl AsRef<str>, f: F)
where F: Fn(&'lua Lua) -> Result<R> + MaybeSend + 'static, R: IntoLua<'lua>,

Add a metatable field computed from f. Read more
source§

impl<'lua, T: 'static> UserDataMethods<'lua, T> for UserDataRegistry<'lua, T>

source§

fn add_method<M, A, R>(&mut self, name: impl AsRef<str>, method: M)
where M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a regular method which accepts a &T as the first parameter. Read more
source§

fn add_method_mut<M, A, R>(&mut self, name: impl AsRef<str>, method: M)
where M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a regular method which accepts a &mut T as the first parameter. Read more
source§

fn add_async_method<'s, M, A, MR, R>( &mut self, name: impl AsRef<str>, method: M )
where T: 'static, M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua>, MR: Future<Output = Result<R>> + 's, R: IntoLuaMulti<'lua>, 'lua: 's,

Available on crate feature async only.
Add an async method which accepts a &T as the first parameter and returns Future. Read more
source§

fn add_async_method_mut<'s, M, A, MR, R>( &mut self, name: impl AsRef<str>, method: M )
where T: 'static, M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua>, MR: Future<Output = Result<R>> + 's, R: IntoLuaMulti<'lua>, 'lua: 's,

Available on crate feature async only.
Add an async method which accepts a &mut T as the first parameter and returns Future. Read more
source§

fn add_function<F, A, R>(&mut self, name: impl AsRef<str>, function: F)
where F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a regular method as a function which accepts generic arguments, the first argument will be a AnyUserData of type T if the method is called with Lua method syntax: my_userdata:my_method(arg1, arg2), or it is passed in as the first argument: my_userdata.my_method(my_userdata, arg1, arg2). Read more
source§

fn add_function_mut<F, A, R>(&mut self, name: impl AsRef<str>, function: F)
where F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a regular method as a mutable function which accepts generic arguments. Read more
source§

fn add_async_function<F, A, FR, R>( &mut self, name: impl AsRef<str>, function: F )
where F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static, A: FromLuaMulti<'lua>, FR: Future<Output = Result<R>> + 'lua, R: IntoLuaMulti<'lua>,

Available on crate feature async only.
Add a regular method as an async function which accepts generic arguments and returns Future. Read more
source§

fn add_meta_method<M, A, R>(&mut self, name: impl AsRef<str>, method: M)
where M: Fn(&'lua Lua, &T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a metamethod which accepts a &T as the first parameter. Read more
source§

fn add_meta_method_mut<M, A, R>(&mut self, name: impl AsRef<str>, method: M)
where M: FnMut(&'lua Lua, &mut T, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a metamethod as a function which accepts a &mut T as the first parameter. Read more
source§

fn add_async_meta_method<'s, M, A, MR, R>( &mut self, name: impl AsRef<str>, method: M )
where T: 'static, M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua>, MR: Future<Output = Result<R>> + 's, R: IntoLuaMulti<'lua>, 'lua: 's,

Available on crate feature async only.
Add an async metamethod which accepts a &T as the first parameter and returns Future. Read more
source§

fn add_async_meta_method_mut<'s, M, A, MR, R>( &mut self, name: impl AsRef<str>, method: M )
where T: 'static, M: Fn(&'lua Lua, &'s mut T, A) -> MR + MaybeSend + 'static, A: FromLuaMulti<'lua>, MR: Future<Output = Result<R>> + 's, R: IntoLuaMulti<'lua>, 'lua: 's,

Available on crate feature async only.
Add an async metamethod which accepts a &mut T as the first parameter and returns Future. Read more
source§

fn add_meta_function<F, A, R>(&mut self, name: impl AsRef<str>, function: F)
where F: Fn(&'lua Lua, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a metamethod which accepts generic arguments. Read more
source§

fn add_meta_function_mut<F, A, R>(&mut self, name: impl AsRef<str>, function: F)
where F: FnMut(&'lua Lua, A) -> Result<R> + MaybeSend + 'static, A: FromLuaMulti<'lua>, R: IntoLuaMulti<'lua>,

Add a metamethod as a mutable function which accepts generic arguments. Read more
source§

fn add_async_meta_function<F, A, FR, R>( &mut self, name: impl AsRef<str>, function: F )
where F: Fn(&'lua Lua, A) -> FR + MaybeSend + 'static, A: FromLuaMulti<'lua>, FR: Future<Output = Result<R>> + 'lua, R: IntoLuaMulti<'lua>,

Available on crate feature async only.
Add a metamethod which accepts generic arguments and returns Future. Read more

Auto Trait Implementations§

§

impl<'lua, T> Freeze for UserDataRegistry<'lua, T>

§

impl<'lua, T> !RefUnwindSafe for UserDataRegistry<'lua, T>

§

impl<'lua, T> !Send for UserDataRegistry<'lua, T>

§

impl<'lua, T> !Sync for UserDataRegistry<'lua, T>

§

impl<'lua, T> Unpin for UserDataRegistry<'lua, T>
where T: Unpin,

§

impl<'lua, T> !UnwindSafe for UserDataRegistry<'lua, T>

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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.