Skip to main content

UserData

Struct UserData 

Source
pub struct UserData<A, T: ?Sized> { /* private fields */ }
Expand description

Lua full userdata.

Use Lua::create_ud() or Context::create_ud() to create the value of this type.

§Types that implement [PropertyKey]

You can pass a value of the following types for property name:

  • Reference to str.

Implementations§

Source§

impl<A, T: Any> UserData<A, T>

Source

pub fn value(&self) -> &T

Returns a reference to the encapsulated value.

Source§

impl<A, T: ?Sized> UserData<A, T>

Source

pub fn get<K: PropertyKey>(&self, name: K) -> Value<'_, A>

Gets a property of this userdata.

See UserData for a list of supported value on name.

Source

pub fn set<K: PropertyKey>(&self, name: K, value: impl Into<UnsafeValue<A>>)

Sets a property of this userdata.

Once this method is called the index operation on this userdata no longer report an error even if this userdata does not have a metatable or no __index on its metatable.

See UserData for a list of supported value on name.

§Panics

If value was created from different Lua instance.

Source§

impl<A> UserData<A, dyn Any>

Source

pub fn is<T: Any>(&self) -> bool

Returns true if the encapsulated value is T.

Source

pub fn downcast<T: Any>(&self) -> Option<&UserData<A, T>>

Attempts to downcast the userdata to a concrete type.

Auto Trait Implementations§

§

impl<A, T> !Freeze for UserData<A, T>

§

impl<A, T> !RefUnwindSafe for UserData<A, T>

§

impl<A, T> !Send for UserData<A, T>

§

impl<A, T> !Sync for UserData<A, T>

§

impl<A, T> !Unpin for UserData<A, T>

§

impl<A, T> !UnwindSafe for UserData<A, 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>,

Source§

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

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V