Struct rlua::AnyUserData
source · [−]pub struct AnyUserData<'lua>(_);
Expand description
Handle to an internal Lua userdata for any type that implements UserData
.
Similar to std::any::Any
, this provides an interface for dynamic type checking via the is
and borrow
methods.
Internally, instances are stored in a RefCell
, to best match the mutable semantics of the Lua
language.
Note
This API should only be used when necessary. Implementing UserData
already allows defining
methods which check the type and acquire a borrow behind the scenes.
Implementations
Borrow this userdata immutably if it is of type T
.
Errors
Returns a UserDataBorrowError
if the userdata is already mutably borrowed. Returns a
UserDataTypeMismatch
if the userdata is not of type T
.
Borrow this userdata mutably if it is of type T
.
Errors
Returns a UserDataBorrowMutError
if the userdata is already borrowed. Returns a
UserDataTypeMismatch
if the userdata is not of type T
.
Sets an associated value to this AnyUserData
.
The value may be any Lua value whatsoever, and can be retrieved with AnyUserData::get_user_value
.
Equivalent to set_i_user_value(v, 1)
Sets an associated value to this AnyUserData
.
The value may be any Lua value whatsoever, and can be retrieved with get_i_user_value
.
Returns an associated value set by set_user_value
.
Returns an associated value set by set_i_user_value
.
Trait Implementations
Auto Trait Implementations
impl<'lua> !RefUnwindSafe for AnyUserData<'lua>
impl<'lua> !Send for AnyUserData<'lua>
impl<'lua> !Sync for AnyUserData<'lua>
impl<'lua> Unpin for AnyUserData<'lua>
impl<'lua> !UnwindSafe for AnyUserData<'lua>
Blanket Implementations
Mutably borrows from an owned value. Read more