pub trait UserData: Sized {
type Trans: UserDataTrans<Self> = Self;
const TYPE_NAME: &'static str = _;
const INDEX_USERVALUE: bool = false;
const RAW_LEN: bool = false;
const WEAK_REF_CACHE: bool = true;
const ACCESS_ERROR: bool = true;
const METATABLE_KEY: MetatableKey = _;
// Provided methods
fn metatable_key() -> MetatableKey { ... }
fn methods(methods: UserdataRegistry<'_, Self>) -> Result<()> { ... }
fn getter(fields: UserdataRegistry<'_, Self>) -> Result<()> { ... }
fn setter(fields: UserdataRegistry<'_, Self>) -> Result<()> { ... }
fn metatable(mt: UserdataRegistry<'_, Self>) -> Result<()> { ... }
fn init_userdata(
this: &Self::Trans,
s: &State,
udata: &LuaUserData<'_>
) -> Result<()> { ... }
fn key_to_cache(&self) -> *const () { ... }
fn uservalue_count(&self, s: &State) -> i32 { ... }
unsafe extern "C" fn __index(l: *mut lua_State) -> c_int { ... }
unsafe extern "C" fn __newindex(l: *mut lua_State) -> c_int { ... }
unsafe extern "C" fn __close(l: *mut lua_State) -> c_int { ... }
}Expand description
Bind rust types as lua userdata, which can make lua access rust methods as lua methods or properties
Provided Associated Types§
type Trans: UserDataTrans<Self> = Self
Provided Associated Constants§
sourceconst INDEX_USERVALUE: bool = false
const INDEX_USERVALUE: bool = false
get/set value from the first uservalue when read/write property
sourceconst RAW_LEN: bool = false
const RAW_LEN: bool = false
set the __len metamethod, if true, return the size of this userdata
sourceconst WEAK_REF_CACHE: bool = true
const WEAK_REF_CACHE: bool = true
set the cache table is a weaked reference if key_to_cache enabled
sourceconst ACCESS_ERROR: bool = true
const ACCESS_ERROR: bool = true
whether raising error when accessing non-exists property
const METATABLE_KEY: MetatableKey = _
Provided Methods§
fn metatable_key() -> MetatableKey
sourcefn methods(methods: UserdataRegistry<'_, Self>) -> Result<()>
fn methods(methods: UserdataRegistry<'_, Self>) -> Result<()>
add methods
sourcefn getter(fields: UserdataRegistry<'_, Self>) -> Result<()>
fn getter(fields: UserdataRegistry<'_, Self>) -> Result<()>
add fields getter
sourcefn setter(fields: UserdataRegistry<'_, Self>) -> Result<()>
fn setter(fields: UserdataRegistry<'_, Self>) -> Result<()>
add fields setter
sourcefn metatable(mt: UserdataRegistry<'_, Self>) -> Result<()>
fn metatable(mt: UserdataRegistry<'_, Self>) -> Result<()>
add else meta methods, and you can acquire or overwrite the generated metamethods
sourcefn init_userdata(
this: &Self::Trans,
s: &State,
udata: &LuaUserData<'_>
) -> Result<()>
fn init_userdata( this: &Self::Trans, s: &State, udata: &LuaUserData<'_> ) -> Result<()>
initialize userdata on the top of lua stack
sourcefn key_to_cache(&self) -> *const ()
fn key_to_cache(&self) -> *const ()
get a pointer whose type is lightuserdata as the key in cache table
fn uservalue_count(&self, s: &State) -> i32
unsafe extern "C" fn __index(l: *mut lua_State) -> c_int
unsafe extern "C" fn __newindex(l: *mut lua_State) -> c_int
unsafe extern "C" fn __close(l: *mut lua_State) -> c_int
Object Safety§
This trait is not object safe.