pub enum Value {
}Expand description
A dynamically typed Lua value.
Mirrors mlua::Value. Reference-typed variants (Value::String,
Value::Table, Value::Function) carry handles that keep both the
value and the VM alive.
Variants§
Nil
nil.
Boolean(bool)
A boolean.
Integer(Integer)
An integer (an f64 that is an exact, in-range whole number).
Number(Number)
A floating-point number.
String(LuaString)
A string.
Table(Table)
A table.
Function(Function)
A function (Lua or Rust).
LightUserData(LightUserData)
A raw-pointer light userdata. Mirrors mlua::Value::LightUserData.
UserData(AnyUserData)
A userdata value with typed Rust-side borrowing.
Thread(Thread)
A thread (coroutine).
Vector(Vector)
A Luau vector (3 f32 components). Mirrors mlua::Value::Vector.
Buffer(Buffer)
A Luau buffer (mutable, fixed-size byte array). Mirrors
mlua::Value::Buffer.
Error(Box<Error>)
A boxed Lua/Rust error carried as a first-class value (mirrors
mlua::Value::Error). Produced when a Rust error is returned to Lua.
Implementations§
Source§impl Value
impl Value
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The Lua type name of this value (e.g. "nil", "number", "table").
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Whether this is a boolean.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Whether this is the integer subtype.
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Whether this is a function.
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Lua truthiness: everything except nil and false is truthy.
Sourcepub fn as_integer(&self) -> Option<Integer>
pub fn as_integer(&self) -> Option<Integer>
View as an integer if it is one.
Sourcepub fn as_function(&self) -> Option<&Function>
pub fn as_function(&self) -> Option<&Function>
View as a function handle.
Sourcepub fn is_userdata(&self) -> bool
pub fn is_userdata(&self) -> bool
Whether this is a userdata value.
Sourcepub fn as_userdata(&self) -> Option<&AnyUserData>
pub fn as_userdata(&self) -> Option<&AnyUserData>
View as a userdata handle.
Sourcepub fn is_vector(&self) -> bool
pub fn is_vector(&self) -> bool
Whether this is a Luau vector value. Mirrors mlua::Value::is_vector.
Sourcepub fn is_buffer(&self) -> bool
pub fn is_buffer(&self) -> bool
Whether this is a Luau buffer value. Mirrors mlua::Value::is_buffer.
Sourcepub fn as_buffer(&self) -> Option<&Buffer>
pub fn as_buffer(&self) -> Option<&Buffer>
View as a buffer handle. Mirrors mlua::Value::as_buffer.
Sourcepub fn to_pointer(&self) -> *const c_void
pub fn to_pointer(&self) -> *const c_void
A raw pointer identifying reference-typed values (tables, functions,
strings, userdata). Returns null for value-typed (nil/bool/number)
values. Mirrors mlua::Value::to_pointer.
Trait Implementations§
Source§impl FromIterator<Value> for MultiValue
impl FromIterator<Value> for MultiValue
Source§impl FromLua for Value
impl FromLua for Value
Source§fn from_lua_arg(
arg: Value,
_i: usize,
_to: Option<&str>,
lua: &Lua,
) -> Result<Self>
fn from_lua_arg( arg: Value, _i: usize, _to: Option<&str>, lua: &Lua, ) -> Result<Self>
i. The default forwards to
FromLua::from_lua; specific impls can produce nicer messages.
Mirrors mlua::FromLua::from_lua_arg.