lua_types/status.rs
1//! `LuaStatus` — return codes matching C-Lua's LUA_OK / LUA_ERR* constants.
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4#[repr(i32)]
5pub enum LuaStatus {
6 Ok = 0,
7 Yield = 1,
8 ErrRun = 2,
9 ErrSyntax = 3,
10 ErrMem = 4,
11 ErrErr = 5,
12 ErrFile = 6,
13 ErrGc = 7,
14}
15
16impl LuaStatus {
17 pub fn from_raw(n: i32) -> Self {
18 match n {
19 0 => Self::Ok,
20 1 => Self::Yield,
21 2 => Self::ErrRun,
22 3 => Self::ErrSyntax,
23 4 => Self::ErrMem,
24 5 => Self::ErrErr,
25 6 => Self::ErrFile,
26 _ => Self::ErrGc,
27 }
28 }
29}
30
31// ──────────────────────────────────────────────────────────────────────────────
32// PORT STATUS
33// source: src/lua.h (LUA_OK / LUA_YIELD / LUA_ERR*)
34// target_crate: lua-types
35// confidence: high
36// todos: 0
37// port_notes: 0
38// unsafe_blocks: 0
39// notes: LuaStatus enum. Mirrors C's status constants used as return codes from
40// lua_pcall / lua_resume / lua_load.
41// ──────────────────────────────────────────────────────────────────────────────