From ae7570bf1a68ed41403bab078b508be53de88988 Mon Sep 17 00:00:00 2001 From: Poga Po Date: Wed, 25 Jul 2018 18:00:55 +0800 Subject: [PATCH] add README and LICENSE --- LICENSE | 25 +++++++++++++++++++++++ README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fd211ba --- /dev/null +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff7230c --- /dev/null +++ b/README.md @@ -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 \ No newline at end of file