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
+35-35Lines changed: 35 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,12 +23,12 @@
23
23
>
24
24
> See v0.10 [release notes](https://github.com/mlua-rs/mlua/blob/main/docs/release_notes/v0.10.md).
25
25
26
-
`mlua` is bindings to [Lua](https://www.lua.org) programming language for Rust with a goal to provide
27
-
_safe_ (as far as it's possible), high level, easy to use, practical and flexible API.
26
+
`mlua` is a set of bindings to the [Lua](https://www.lua.org) programming language for Rust with a goal to provide a
27
+
_safe_ (as much as possible), high level, easy to use, practical and flexible API.
28
28
29
-
Started as `rlua` fork, `mlua` supports Lua 5.4, 5.3, 5.2, 5.1 (including LuaJIT) and [Luau] and allows to write native Lua modules in Rust as well as use Lua in a standalone mode.
29
+
Started as an `rlua` fork, `mlua` supports Lua 5.4, 5.3, 5.2, 5.1 (including LuaJIT) and [Luau] and allows writing native Lua modules in Rust as well as using Lua in a standalone mode.
30
30
31
-
`mlua` tested on Windows/macOS/Linux including module mode in [GitHub Actions] on `x86_64`platform and cross-compilation to `aarch64` (other targets are also supported).
31
+
`mlua`is tested on Windows/macOS/Linux including module mode in [GitHub Actions] on `x86_64`platforms and cross-compilation to `aarch64` (other targets are also supported).
32
32
33
33
WebAssembly (WASM) is supported through `wasm32-unknown-emscripten` target for all Lua/Luau versions excluding JIT.
34
34
@@ -39,7 +39,7 @@ WebAssembly (WASM) is supported through `wasm32-unknown-emscripten` target for a
39
39
40
40
### Feature flags
41
41
42
-
`mlua` uses feature flags to reduce the amount of dependencies, compiled code and allow to choose only required set of features.
42
+
`mlua` uses feature flags to reduce the amount of dependencies and compiled code, and allow to choose only required set of features.
43
43
Below is a list of the available feature flags. By default `mlua` does not enable any features.
44
44
45
45
*`lua54`: enable Lua [5.4] support
@@ -51,12 +51,12 @@ Below is a list of the available feature flags. By default `mlua` does not enabl
51
51
*`luau`: enable [Luau] support (auto vendored mode)
52
52
*`luau-jit`: enable [Luau] support with JIT backend.
53
53
*`luau-vector4`: enable [Luau] support with 4-dimensional vector.
54
-
*`vendored`: build static Lua(JIT) library from sources during `mlua` compilation using [lua-src] or [luajit-src] crates
54
+
*`vendored`: build static Lua(JIT) libraries from sources during `mlua` compilation using [lua-src] or [luajit-src]
55
55
*`module`: enable module mode (building loadable `cdylib` library for Lua)
56
56
*`async`: enable async/await support (any executor can be used, eg. [tokio] or [async-std])
57
57
*`send`: make `mlua::Lua: Send + Sync` (adds [`Send`] requirement to `mlua::Function` and `mlua::UserData`)
58
58
*`error-send`: make `mlua:Error: Send + Sync`
59
-
*`serialize`: add serialization and deserialization support to `mlua` types using [serde] framework
59
+
*`serialize`: add serialization and deserialization support to `mlua` types using [serde]
60
60
*`macros`: enable procedural macros (such as `chunk!`)
61
61
*`anyhow`: enable `anyhow::Error` conversion into Lua
62
62
*`userdata-wrappers`: opt into `impl UserData` for `Rc<T>`/`Arc<T>`/`Rc<RefCell<T>>`/`Arc<Mutex<T>>` where `T: UserData`
@@ -78,7 +78,7 @@ Below is a list of the available feature flags. By default `mlua` does not enabl
78
78
79
79
`mlua` supports async/await for all Lua versions including Luau.
80
80
81
-
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`.
81
+
This works using Lua [coroutines](https://www.lua.org/manual/5.3/manual.html#2.6) and requires running [Thread](https://docs.rs/mlua/latest/mlua/struct.Thread.html) along with enabling `feature = "async"` in `Cargo.toml`.
82
82
83
83
**Examples**:
84
84
-[HTTP Client](examples/async_http_client.rs)
@@ -102,7 +102,7 @@ curl -v http://localhost:3000
102
102
103
103
### Serialization (serde) support
104
104
105
-
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).
105
+
With the `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 the[`serde::Serialize`] trait implementation for it (including `UserData` support).
106
106
107
107
[Example](examples/serialize.rs)
108
108
@@ -114,24 +114,24 @@ With `serialize` feature flag enabled, `mlua` allows you to serialize/deserializ
114
114
115
115
You have to enable one of the features: `lua54`, `lua53`, `lua52`, `lua51`, `luajit(52)` or `luau`, according to the chosen Lua version.
116
116
117
-
By default `mlua` uses `pkg-config`tool to find lua includes and libraries for the chosen Lua version.
118
-
In most cases it works as desired, although sometimes could be more preferable to use a custom lua library.
119
-
To achieve this, mlua supports `LUA_LIB`, `LUA_LIB_NAME` and `LUA_LINK` environment variables.
117
+
By default `mlua` uses `pkg-config` to find Lua includes and libraries for the chosen Lua version.
118
+
In most cases it works as desired, although sometimes it may be preferable to use a custom Lua library.
119
+
To achieve this, mlua supports the `LUA_LIB`, `LUA_LIB_NAME` and `LUA_LINK` environment variables.
120
120
`LUA_LINK` is optional and may be `dylib` (a dynamic library) or `static` (a static library, `.a` archive).
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`.
129
+
Just enable the `vendored` feature and cargo will automatically build and link the specified Lua/LuaJIT version. This is the easiest way to get started with `mlua`.
130
130
131
131
### Standalone mode
132
-
In a standalone mode `mlua` allows to add to your application scripting support with a gently configured Lua runtime to ensure safety and soundness.
132
+
In standalone mode,`mlua` allows adding scripting support to your application with a gently configured Lua runtime to ensure safety and soundness.
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.4/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.4/manual.html#6.10).
162
+
In module mode,`mlua` allows creating a compiled Lua module that can be loaded from Lua code using [`require`](https://www.lua.org/manual/5.4/manual.html#pdf-require). In this case `mlua` uses an external Lua runtime which could lead to potential unsafety due to the unpredictability of the Lua environment and usage of libraries such as [`debug`](https://www.lua.org/manual/5.4/manual.html#6.10).
163
163
164
164
[Example](examples/module)
165
165
166
-
Add to `Cargo.toml`:
166
+
Add to `Cargo.toml`:
167
167
168
168
```toml
169
169
[lib]
@@ -173,7 +173,7 @@ crate-type = ["cdylib"]
173
173
mlua = { version = "0.10", features = ["lua54", "module"] }
174
174
```
175
175
176
-
`lib.rs`:
176
+
`lib.rs`:
177
177
178
178
```rust
179
179
usemlua::prelude::*;
@@ -216,14 +216,14 @@ rustflags = [
216
216
```
217
217
On Linux you can build modules normally with `cargo build --release`.
218
218
219
-
On Windows the target module will be linked with `lua5x.dll` library (depending on your feature flags).
219
+
On Windows the target module will be linked with the `lua5x.dll` library (depending on your feature flags).
220
220
Your main application should provide this library.
221
221
222
-
Module builds don't require Lua lib or headers to be installed on the system.
222
+
Module builds don't require Lua binaries or headers to be installed on the system.
223
223
224
224
### Publishing to luarocks.org
225
225
226
-
There is a LuaRocks build backend for mlua modules [`luarocks-build-rust-mlua`].
226
+
There is a LuaRocks build backend for mlua modules:[`luarocks-build-rust-mlua`].
227
227
228
228
Modules written in Rust and published to luarocks:
0 commit comments