Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit ae7570b

Browse files
committed
add README and LICENSE
1 parent df68124 commit ae7570b

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2018 Chieh Po
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Actix-Lua
2+
3+
[Actix](https://github.com/actix/actix) actor with [Lua](https://www.lua.org/).
4+
5+
## Features
6+
7+
* Handling messages with Lua
8+
* Dynamic message type
9+
10+
## Usage
11+
12+
Add `actix-lua` to your `Cargo.toml`:
13+
14+
```toml
15+
[dependencies]
16+
actix-lua = "0.1"
17+
```
18+
19+
#### Implement an Actor
20+
21+
You can define an actor with Lua, for example:
22+
23+
```rust
24+
extern crate actix_lua;
25+
use actix_lua::{LuaActor, LuaMessage};
26+
27+
fn main () {
28+
let system = System::new("test");
29+
let addr = LuaActor::new(r#"
30+
function handle(msg)
31+
return msg + 42
32+
end
33+
"#).unwrap().start();
34+
35+
let res = add.send(LuaMessage:from(123));
36+
}
37+
```
38+
39+
## Message Type
40+
41+
`LuaActor` only accept messages with type `LuaMessage`. The result of `LuaMessage` is also `LuaMessage`.
42+
43+
`LuaMessage` is defined as:
44+
45+
```rust
46+
pub enum LuaMessage {
47+
String(String),
48+
Integer(i64),
49+
Number(f64),
50+
Boolean(bool),
51+
Nil,
52+
}
53+
```
54+
55+
It's the sender's job to check the returned value type from Lua is what they want.
56+
57+
## License
58+
59+
The MIT License

0 commit comments

Comments
 (0)