Trait ezlua::userdata::UserData

source ·
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§

source

type Trans: UserDataTrans<Self> = Self

Provided Associated Constants§

source

const TYPE_NAME: &'static str = _

__name field in metatable

source

const INDEX_USERVALUE: bool = false

get/set value from the first uservalue when read/write property

source

const RAW_LEN: bool = false

set the __len metamethod, if true, return the size of this userdata

source

const WEAK_REF_CACHE: bool = true

set the cache table is a weaked reference if key_to_cache enabled

source

const ACCESS_ERROR: bool = true

whether raising error when accessing non-exists property

source

const METATABLE_KEY: MetatableKey = _

Provided Methods§

source

fn metatable_key() -> MetatableKey

source

fn methods(methods: UserdataRegistry<'_, Self>) -> Result<()>

add methods

source

fn getter(fields: UserdataRegistry<'_, Self>) -> Result<()>

add fields getter

source

fn setter(fields: UserdataRegistry<'_, Self>) -> Result<()>

add fields setter

source

fn metatable(mt: UserdataRegistry<'_, Self>) -> Result<()>

add else meta methods, and you can acquire or overwrite the generated metamethods

source

fn init_userdata( this: &Self::Trans, s: &State, udata: &LuaUserData<'_> ) -> Result<()>

initialize userdata on the top of lua stack

source

fn key_to_cache(&self) -> *const ()

get a pointer whose type is lightuserdata as the key in cache table

source

fn uservalue_count(&self, s: &State) -> i32

source

unsafe extern "C" fn __index(l: *mut lua_State) -> c_int

source

unsafe extern "C" fn __newindex(l: *mut lua_State) -> c_int

source

unsafe extern "C" fn __close(l: *mut lua_State) -> c_int

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl UserData for DirEntry

source§

fn getter(fields: UserdataRegistry<'_, Self>) -> LuaResult<()>

source§

fn methods(methods: UserdataRegistry<'_, Self>) -> LuaResult<()>

source§

impl UserData for Metadata

source§

fn getter(fields: UserdataRegistry<'_, Self>) -> Result<()>

source§

fn methods(mt: UserdataRegistry<'_, Self>) -> Result<()>

source§

impl UserData for Child

source§

impl UserData for Command

Implementors§