Skip to main content

AsyncReturnValue

Enum AsyncReturnValue 

Source
pub enum AsyncReturnValue {
    Value(LuaValue),
    String(String),
    UserData(LuaUserdata),
}
Expand description

Return value from an async function.

Because LuaValue strings are GC-managed and can only be created through the VM, async futures cannot directly construct string LuaValues. Instead, they return AsyncReturnValues which are converted to LuaValues by the AsyncThread after the future completes (using the VM’s string interner).

For non-GC types (integers, floats, booleans, nil), the value is stored directly as a LuaValue. For strings, an owned String is stored and later interned via vm.create_string(). For userdata, a LuaUserdata is stored and later GC-allocated via vm.create_userdata().

Variants§

§

Value(LuaValue)

A value that doesn’t need GC allocation (integer, float, bool, nil, lightuserdata)

§

String(String)

A string that needs to be interned via the VM’s string pool

§

UserData(LuaUserdata)

A userdata that needs to be GC-allocated via the VM

Implementations§

Source§

impl AsyncReturnValue

Source

pub fn nil() -> Self

Create a nil return value

Source

pub fn integer(n: i64) -> Self

Create an integer return value

Source

pub fn float(n: f64) -> Self

Create a float return value

Source

pub fn boolean(b: bool) -> Self

Create a boolean return value

Source

pub fn string(s: impl Into<String>) -> Self

Create a string return value (will be interned when passed back to Lua)

Source

pub fn userdata<T: UserDataTrait>(data: T) -> Self

Create a userdata return value (will be GC-allocated when passed back to Lua)

Trait Implementations§

Source§

impl From<&str> for AsyncReturnValue

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<LuaUserdata> for AsyncReturnValue

Source§

fn from(ud: LuaUserdata) -> Self

Converts to this type from the input type.
Source§

impl From<LuaValue> for AsyncReturnValue

Source§

fn from(v: LuaValue) -> Self

Converts to this type from the input type.
Source§

impl From<String> for AsyncReturnValue

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for AsyncReturnValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for AsyncReturnValue

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for AsyncReturnValue

Convenience conversions

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> LuaMethodProvider for T

Source§

impl<T> LuaStaticMethodProvider for T

Source§

fn __lua_static_methods() -> &'static [(&'static str, CFunction)]

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.