pub struct LuaDatum<'a, 'b, 'c>(_);
Expand description

Lua value (of any supported type)

A LuaDatum is used to pass values from Rust to Lua and vice versa. It can contain values of several types (dynamic typing). See module sandkiste::types for more information.

Lifetimes

Lifetime argument 'a corresponds to the lifetime argument 'a of LuaMachine. It is a lower bound for closures passed to the Lua machine.

Lifetime argument 'b corresponds to the lifetime of the shared reference to the LuaMachine being worked with.

Lifetime argument 'c is often 'static but can be a shorter lifetime for temporary LuaDatums created from a &'c str reference, for example.

Trait Implementations§

source§

impl<'a, 'b, 'c> Clone for LuaDatum<'a, 'b, 'c>

source§

fn clone(&self) -> LuaDatum<'a, 'b, 'c>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, 'b, 'c> Debug for LuaDatum<'a, 'b, 'c>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, 'b, 'c> From<&'c [u8]> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: &'c [u8]) -> LuaDatum<'a, 'b, 'c>

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<&'c str> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: &'c str) -> LuaDatum<'a, 'b, 'c>

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<LuaFunction<'a, 'b>> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: LuaFunction<'a, 'b>) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c, T> From<Option<T>> for LuaDatum<'a, 'b, 'c>where T: Into<Self>,

source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<String> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: String) -> LuaDatum<'a, 'b, 'c>

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<Vec<u8, Global>> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: Vec<u8>) -> LuaDatum<'a, 'b, 'c>

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<bool> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<f32> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<f64> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<i16> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<i32> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<i8> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<u16> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> From<u8> for LuaDatum<'a, 'b, 'c>

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, 'c> MaybeArray for LuaDatum<'a, 'b, 'c>

§

type Element<'d> = LuaDatum<'a, 'b, 'd>

Type of elements
source§

fn try_array(&self) -> Result<(), TypeMismatch>

Return error unless datum is an array-like type
source§

fn array_len(&self) -> Result<usize, MachineError>

Array length
source§

fn array_get( &self, index: usize ) -> Result<LuaDatum<'a, 'b, 'static>, MachineError>

Retrieve element at index Read more
source§

fn array_set<'d>( &self, index: usize, element: LuaDatum<'a, 'b, 'd> ) -> Result<(), MachineError>

Set element at index Read more
source§

fn array_push<'d>( &self, element: LuaDatum<'a, 'b, 'd> ) -> Result<(), MachineError>

Push element to array
source§

fn array_truncate(&self, len: usize) -> Result<(), MachineError>

Truncate array
source§

fn array_to_iter<'b>(&'b self) -> Result<ArrayIter<'b, Self>, MachineError>

Create Iterator over entries of array-like datum
source§

fn array_to_vec( &self, maxlen: usize ) -> Result<Vec<Self::Element<'static>, Global>, MachineError>

Create Vec from array-like datum
source§

impl<'a, 'b, 'c> MaybeBinary<'c> for LuaDatum<'a, 'b, 'c>

source§

fn try_as_bin(&self) -> Result<&[u8], TypeMismatch>

Try to interpret datum as binary (8 bit) string
source§

fn try_into_binary(self) -> Result<Vec<u8, Global>, TypeMismatch>

Try to convert datum into binary (8 bit) string
source§

impl<'a, 'b, 'c> MaybeBoolean for LuaDatum<'a, 'b, 'c>

source§

fn try_as_bool(&self) -> Result<bool, TypeMismatch>

Try to interpret datum as boolean value
source§

impl<'a, 'b, 'c> MaybeFloat for LuaDatum<'a, 'b, 'c>

source§

fn try_as_f64(&self) -> Result<f64, TypeMismatch>

Try to interpret datum as f64
source§

fn try_as_f32(&self) -> Result<f32, TypeMismatch>

Try to interpret datum as f64
source§

impl<'a, 'b, 'c> MaybeFunction for LuaDatum<'a, 'b, 'c>

§

type Function = LuaFunction<'a, 'b>

Function type (see Machine::Function)
§

type FunctionRef<'d> where Self: 'd = &'d LuaFunction<'a, 'b>

Reference or smart pointer to MaybeFunction::Function as returned by try_as_function
source§

fn try_as_function(&self) -> Result<&LuaFunction<'a, 'b>, TypeMismatch>

Try to interpret datum as function
source§

impl<'a, 'b, 'c> MaybeInteger for LuaDatum<'a, 'b, 'c>

source§

fn try_as_i64(&self) -> Result<i64, TypeMismatch>

Try to interpret datum as i64
source§

fn try_as_u64(&self) -> Result<u64, TypeMismatch>

Try to interpret datum as u64
source§

fn try_as_i32(&self) -> Result<i32, TypeMismatch>

Try to interpret datum as i32
source§

fn try_as_u32(&self) -> Result<u32, TypeMismatch>

Try to interpret datum as u32
source§

fn try_as_i16(&self) -> Result<i16, TypeMismatch>

Try to interpret datum as i16
source§

fn try_as_u16(&self) -> Result<u16, TypeMismatch>

Try to interpret datum as u16
source§

fn try_as_i8(&self) -> Result<i8, TypeMismatch>

Try to interpret datum as i8
source§

fn try_as_u8(&self) -> Result<u8, TypeMismatch>

Try to interpret datum as u8
source§

fn try_as_isize(&self) -> Result<usize, TypeMismatch>

Try to interpret datum as isize
source§

fn try_as_usize(&self) -> Result<usize, TypeMismatch>

Try to interpret datum as usize
source§

impl<'a, 'b, 'c> MaybeOpaque for LuaDatum<'a, 'b, 'c>

§

type Opaque = LuaReference<'a, 'b>

Type used to represent reference to an opaque datum
§

type OpaqueRef<'d> where Self: 'd = &'d LuaReference<'a, 'b>

Reference or smart pointer to MaybeOpaque::Opaque as returned by try_as_opaque
source§

fn is_opaque(&self) -> bool

Can the datum be interpreted as an opaque value?
source§

fn try_as_opaque(&self) -> Result<&LuaReference<'a, 'b>, TypeMismatch>

Try to interpret datum as reference to opaque datum
source§

fn try_into_opaque(self) -> Result<Self::Opaque, TypeMismatch>

Try to convert datum into opaque datum
source§

impl<'a, 'b, 'c> MaybeString<'c> for LuaDatum<'a, 'b, 'c>

source§

fn try_as_str(&self) -> Result<&str, TypeMismatch>

Try to interpret datum as Unicode string
source§

fn try_into_string(self) -> Result<String, TypeMismatch>

Try to convert datum into Unicode string
source§

impl<'a, 'b, 'c> MaybeStringMap for LuaDatum<'a, 'b, 'c>

§

type Value<'d> = LuaDatum<'a, 'b, 'd>

Type of values
source§

fn try_string_map(&self) -> Result<(), TypeMismatch>

Return error unless datum is a string-map-like type
source§

fn string_map_get( &self, key: &str ) -> Result<LuaDatum<'a, 'b, 'static>, MachineError>

Get entry from string map
source§

fn string_map_set<'d, 'e>( &self, key: &'d str, value: LuaDatum<'a, 'b, 'e> ) -> Result<(), MachineError>

Set entry in string map
source§

impl<'a, 'b, 'c> Nullable for LuaDatum<'a, 'b, 'c>

source§

fn null() -> Self

Datum representing a null value
source§

fn is_null(&self) -> bool

Can the datum be interpreted as a null value?
source§

impl<'a, 'b, 'c> TryFrom<LuaDatum<'a, 'b, 'c>> for LuaReference<'a, 'b>

§

type Error = DatumConversionFailure<LuaDatum<'a, 'b, 'c>>

The type returned in the event of a conversion error.
source§

fn try_from(value: LuaDatum<'a, 'b, 'c>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<LuaDatum<'a, 'b, 'c>> for String

§

type Error = DatumConversionFailure<LuaDatum<'a, 'b, 'c>>

The type returned in the event of a conversion error.
source§

fn try_from(value: LuaDatum<'a, 'b, 'c>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<LuaDatum<'a, 'b, 'c>> for Vec<u8>

§

type Error = DatumConversionFailure<LuaDatum<'a, 'b, 'c>>

The type returned in the event of a conversion error.
source§

fn try_from(value: LuaDatum<'a, 'b, 'c>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<i64> for LuaDatum<'a, 'b, 'c>

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<isize> for LuaDatum<'a, 'b, 'c>

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<u32> for LuaDatum<'a, 'b, 'c>

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<u64> for LuaDatum<'a, 'b, 'c>

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, 'b, 'c> TryFrom<usize> for LuaDatum<'a, 'b, 'c>

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a, 'b, 'c> RefUnwindSafe for LuaDatum<'a, 'b, 'c>

§

impl<'a, 'b, 'c> !Send for LuaDatum<'a, 'b, 'c>

§

impl<'a, 'b, 'c> !Sync for LuaDatum<'a, 'b, 'c>

§

impl<'a, 'b, 'c> Unpin for LuaDatum<'a, 'b, 'c>

§

impl<'a, 'b, 'c> UnwindSafe for LuaDatum<'a, 'b, 'c>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.