You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-13Lines changed: 38 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -13,23 +13,45 @@
13
13
`mlua` is bindings to [Lua](https://www.lua.org) programming language for Rust with a goal to provide
14
14
_safe_ (as far as it's possible), high level, easy to use, practical and flexible API.
15
15
16
-
Started as [rlua v0.15](https://github.com/amethyst/rlua/tree/0.15.3) fork, `mlua` supports *__all__* major Lua versions (including LuaJIT) and allows to write native Lua modules in Rust as well as use Lua in a standalone mode.
16
+
Started as [rlua](https://github.com/amethyst/rlua/tree/0.15.3) fork, `mlua` supports Lua 5.4, 5.3, 5.2 and 5.1 including LuaJIT (2.0.5 and 2.1 beta) and allows to write native Lua modules in Rust as well as use Lua in a standalone mode.
17
17
18
-
`mlua` supports the following Lua versions (and tested on Windows/macOS/Linux):
19
-
- Lua 5.4 (`feature = "lua54"`)
20
-
- Lua 5.3 (`feature = "lua53"`)
21
-
- Lua 5.2 (`feature = "lua52"`)
22
-
- Lua 5.1 (`feature = "lua51"`)
23
-
- LuaJIT 2.1.0 beta (`feature = "luajit"`)
24
-
- LuaJIT 2.0.5 stable (`feature = "luajit"`)
18
+
`mlua` tested on Windows/macOS/Linux including module mode in [GitHub Actions] on `x86_64` platform and cross-compilation to `aarch64` (other targes are also supported).
25
19
26
-
Additional `feature = "vendored"` enables building static Lua from sources during `mlua` compilation.
Starting from v0.3, `mlua` supports async/await for all Lua versions. This works using Lua [coroutines](https://www.lua.org/manual/5.3/manual.html#2.6) and require running [Thread](https://docs.rs/mlua/latest/mlua/struct.Thread.html) along with enabling `feature = "async"` in `Cargo.toml`.
54
+
`mlua` supports async/await for all Lua versions. This works using Lua [coroutines](https://www.lua.org/manual/5.3/manual.html#2.6) and require running [Thread](https://docs.rs/mlua/latest/mlua/struct.Thread.html) along with enabling `feature = "async"` in `Cargo.toml`.
33
55
34
56
**Examples**:
35
57
-[HTTP Client](examples/async_http_client.rs)
@@ -39,7 +61,7 @@ Starting from v0.3, `mlua` supports async/await for all Lua versions. This works
39
61
40
62
### Serialization (serde) support
41
63
42
-
With `serialize` feature flag enabled, `mlua` allows you to serialize/deserialize any type that implements [`serde::Serialize`] and [`serde::Deserialize`] into/from [`mlua::Value`]. In addition `mlua` provides [`serde::Serialize`] trait implementation for it (including user data support).
64
+
With `serialize` feature flag enabled, `mlua` allows you to serialize/deserialize any type that implements [`serde::Serialize`] and [`serde::Deserialize`] into/from [`mlua::Value`]. In addition `mlua` provides [`serde::Serialize`] trait implementation for it (including `UserData` support).
Just enable the `vendored` feature and cargo will automatically build and link specified lua/luajit version. This is the easiest way to get started with `mlua`.
67
89
68
90
### Standalone mode
91
+
In a standalone mode `mlua` allows to add to your application scripting support with a gently configured Lua runtime to ensure safety and soundness.
92
+
69
93
Add to `Cargo.toml` :
70
94
71
95
```toml
72
96
[dependencies]
73
-
mlua = { version = "0.5", features = ["lua53"] }
97
+
mlua = { version = "0.5", features = ["lua53", "vendored"] }
74
98
```
75
99
76
100
`main.rs`
@@ -94,6 +118,7 @@ fn main() -> LuaResult<()> {
94
118
```
95
119
96
120
### Module mode
121
+
In a module mode `mlua` allows to create a compiled Lua module that can be loaded from Lua code using [`require`](https://www.lua.org/manual/5.3/manual.html#pdf-require). In this case `mlua` uses an external Lua runtime which could lead to potential unsafety due to unpredictability of the Lua environment and usage of libraries such as [`debug`](https://www.lua.org/manual/5.3/manual.html#6.10).
97
122
98
123
[Example](examples/module)
99
124
@@ -104,7 +129,7 @@ Add to `Cargo.toml` :
104
129
crate-type = ["cdylib"]
105
130
106
131
[dependencies]
107
-
mlua = { version = "0.5", features = ["lua53", "module"] }
132
+
mlua = { version = "0.5", features = ["lua53", "vendored", "module"] }
0 commit comments