Skip to content

Commit 90bea4a

Browse files
committed
Update README and keywords
1 parent 7775b4a commit 90bea4a

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
repository = "https://github.com/khvzak/mlua"
77
documentation = "https://docs.rs/mlua"
88
readme = "README.md"
9-
keywords = ["lua", "luajit", "async", "futures"]
9+
keywords = ["lua", "luajit", "async", "futures", "scripting"]
1010
categories = ["api-bindings", "asynchronous"]
1111
license = "MIT"
1212
links = "lua"

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,45 @@
1313
`mlua` is bindings to [Lua](https://www.lua.org) programming language for Rust with a goal to provide
1414
_safe_ (as far as it's possible), high level, easy to use, practical and flexible API.
1515

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.
1717

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).
2519

26-
Additional `feature = "vendored"` enables building static Lua from sources during `mlua` compilation.
20+
[GitHub Actions]: https://github.com/khvzak/mlua/actions
2721

2822
## Usage
2923

24+
### Feature flags
25+
26+
`mlua` uses feature flags to reduce the amount of depenendies, compiled code and allow to choose only required set of features.
27+
Below is a list of the available feature flags. By default `mlua` does not enable any features.
28+
29+
* `lua54`: activate Lua [5.4] support
30+
* `lua53`: activate Lua [5.3] support
31+
* `lua52`: activate Lua [5.2] support
32+
* `lua51`: activate Lua [5.1] support
33+
* `luajit`: activate [LuaJIT] support
34+
* `vendored`: build static Lua(JIT) library from sources during `mlua` compilation using [lua-src] or [luajit-src] crates
35+
* `module`: enable module mode (building loadable `cdylib` library for Lua)
36+
* `async`: enable async/await support (any executor can be used, eg. [tokio] or [async-std])
37+
* `send`: make `mlua::Lua` transferable across thread boundaries (adds [`Send`] requirement to `mlua::Function` and `mlua::UserData`)
38+
* `serialize`: add serialization and deserialization support to `mlua` types usign [serde] framework
39+
40+
[5.4]: https://www.lua.org/manual/5.4/manual.html
41+
[5.3]: https://www.lua.org/manual/5.3/manual.html
42+
[5.2]: https://www.lua.org/manual/5.2/manual.html
43+
[5.1]: https://www.lua.org/manual/5.1/manual.html
44+
[LuaJIT]: https://luajit.org/
45+
[lua-src]: https://github.com/khvzak/lua-src-rs
46+
[luajit-src]: https://github.com/khvzak/luajit-src-rs
47+
[tokio]: https://github.com/tokio-rs/tokio
48+
[async-std]: https://github.com/async-rs/async-std
49+
[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
50+
[serde]: https://github.com/serde-rs/serde
51+
3052
### Async/await support
3153

32-
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`.
3355

3456
**Examples**:
3557
- [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
3961

4062
### Serialization (serde) support
4163

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).
4365

4466
[Example](examples/serialize.rs)
4567

@@ -66,11 +88,13 @@ my_project $ LUA_INC=$HOME/tmp/lua-5.2.4/src LUA_LIB=$HOME/tmp/lua-5.2.4/src LUA
6688
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`.
6789

6890
### 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+
6993
Add to `Cargo.toml` :
7094

7195
``` toml
7296
[dependencies]
73-
mlua = { version = "0.5", features = ["lua53"] }
97+
mlua = { version = "0.5", features = ["lua53", "vendored"] }
7498
```
7599

76100
`main.rs`
@@ -94,6 +118,7 @@ fn main() -> LuaResult<()> {
94118
```
95119

96120
### 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).
97122

98123
[Example](examples/module)
99124

@@ -104,7 +129,7 @@ Add to `Cargo.toml` :
104129
crate-type = ["cdylib"]
105130

106131
[dependencies]
107-
mlua = { version = "0.5", features = ["lua53", "module"] }
132+
mlua = { version = "0.5", features = ["lua53", "vendored", "module"] }
108133
```
109134

110135
`lib.rs` :

0 commit comments

Comments
 (0)