Struct rlua::AnyUserData [−][src]
pub struct AnyUserData<'lua>(_);
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.
Methods
impl<'lua> AnyUserData<'lua>[src]
impl<'lua> AnyUserData<'lua>pub fn is<T: UserData>(&self) -> Result<bool>[src]
pub fn is<T: UserData>(&self) -> Result<bool>Checks whether the type of this userdata is T.
pub fn borrow<T: UserData>(&self) -> Result<Ref<T>>[src]
pub fn borrow<T: UserData>(&self) -> Result<Ref<T>>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.
pub fn borrow_mut<T: UserData>(&self) -> Result<RefMut<T>>[src]
pub fn borrow_mut<T: UserData>(&self) -> Result<RefMut<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.
pub fn set_user_value<V: ToLua<'lua>>(&self, v: V) -> Result<()>[src]
pub fn set_user_value<V: ToLua<'lua>>(&self, v: V) -> Result<()>Sets an associated value to this AnyUserData.
The value may be any Lua value whatsoever, and can be retrieved with get_user_value.
pub fn get_user_value<V: FromLua<'lua>>(&self) -> Result<V>[src]
pub fn get_user_value<V: FromLua<'lua>>(&self) -> Result<V>Returns an associated value set by set_user_value.
Trait Implementations
impl<'lua> ToLua<'lua> for AnyUserData<'lua>[src]
impl<'lua> ToLua<'lua> for AnyUserData<'lua>impl<'lua> FromLua<'lua> for AnyUserData<'lua>[src]
impl<'lua> FromLua<'lua> for AnyUserData<'lua>fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<AnyUserData<'lua>>[src]
fn from_lua(value: Value<'lua>, _: &'lua Lua) -> Result<AnyUserData<'lua>>Performs the conversion.
impl<'lua> Clone for AnyUserData<'lua>[src]
impl<'lua> Clone for AnyUserData<'lua>fn clone(&self) -> AnyUserData<'lua>[src]
fn clone(&self) -> AnyUserData<'lua>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<'lua> Debug for AnyUserData<'lua>[src]
impl<'lua> Debug for AnyUserData<'lua>Auto Trait Implementations
impl<'lua> !Send for AnyUserData<'lua>
impl<'lua> !Send for AnyUserData<'lua>impl<'lua> !Sync for AnyUserData<'lua>
impl<'lua> !Sync for AnyUserData<'lua>