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

Commit

Permalink
add README and LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
poga committed Jul 25, 2018
1 parent df68124 commit ae7570b
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2018 Chieh Po

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Actix-Lua

[Actix](https://github.com/actix/actix) actor with [Lua](https://www.lua.org/).

## Features

* Handling messages with Lua
* Dynamic message type

## Usage

Add `actix-lua` to your `Cargo.toml`:

```toml
[dependencies]
actix-lua = "0.1"
```

#### Implement an Actor

You can define an actor with Lua, for example:

```rust
extern crate actix_lua;
use actix_lua::{LuaActor, LuaMessage};

fn main () {
let system = System::new("test");
let addr = LuaActor::new(r#"
function handle(msg)
return msg + 42
end
"#).unwrap().start();

let res = add.send(LuaMessage:from(123));
}
```

## Message Type

`LuaActor` only accept messages with type `LuaMessage`. The result of `LuaMessage` is also `LuaMessage`.

`LuaMessage` is defined as:

```rust
pub enum LuaMessage {
String(String),
Integer(i64),
Number(f64),
Boolean(bool),
Nil,
}
```

It's the sender's job to check the returned value type from Lua is what they want.

## License

The MIT License

0 comments on commit ae7570b

Please sign in to comment.