{"id":15032068,"url":"https://github.com/teaentitylab/rustluaactor","last_synced_at":"2025-04-09T21:23:08.985Z","repository":{"id":57635209,"uuid":"143546385","full_name":"TeaEntityLab/rustLuaActor","owner":"TeaEntityLab","description":"Lua Actor implementation for Rust (in sync/async modes)","archived":false,"fork":false,"pushed_at":"2021-07-26T14:14:20.000Z","size":46,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T23:15:49.524Z","etag":null,"topics":["actor-library","actor-model","async","async-functions","async-programming","asynchronous","asynchronous-programming","asynctask","lua","lua-binding","lua-bindings","lua-library","lua-script","rust","rust-bindings","rust-crate","rust-lang","rust-language","rust-library","rustlang"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TeaEntityLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-04T16:49:33.000Z","updated_at":"2021-10-30T15:04:52.000Z","dependencies_parsed_at":"2022-09-26T20:20:52.865Z","dependency_job_id":null,"html_url":"https://github.com/TeaEntityLab/rustLuaActor","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeaEntityLab%2FrustLuaActor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeaEntityLab%2FrustLuaActor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeaEntityLab%2FrustLuaActor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeaEntityLab%2FrustLuaActor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TeaEntityLab","download_url":"https://codeload.github.com/TeaEntityLab/rustLuaActor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113037,"owners_count":21049770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor-library","actor-model","async","async-functions","async-programming","asynchronous","asynchronous-programming","asynctask","lua","lua-binding","lua-bindings","lua-library","lua-script","rust","rust-bindings","rust-crate","rust-lang","rust-language","rust-library","rustlang"],"created_at":"2024-09-24T20:17:15.105Z","updated_at":"2025-04-09T21:23:08.963Z","avatar_url":"https://github.com/TeaEntityLab.png","language":"Rust","readme":"# rustLuaActor\n\n[![tag](https://img.shields.io/github/tag/TeaEntityLab/rustLuaActor.svg)](https://github.com/TeaEntityLab/rustLuaActor)\n[![Crates.io](https://img.shields.io/crates/d/lua_actor.svg)](https://crates.io/crates/lua_actor)\n[![Travis CI Build Status](https://api.travis-ci.org/TeaEntityLab/rustLuaActor.svg?branch=master)](https://travis-ci.org/TeaEntityLab/rustLuaActor)\n[![docs](https://img.shields.io/badge/docs-online-5023dd.svg)](https://docs.rs/lua_actor/)\n\n[![license](https://img.shields.io/github/license/TeaEntityLab/rustLuaActor.svg?style=social\u0026label=License)](https://github.com/TeaEntityLab/rustLuaActor)\n[![stars](https://img.shields.io/github/stars/TeaEntityLab/rustLuaActor.svg?style=social\u0026label=Stars)](https://github.com/TeaEntityLab/rustLuaActor)\n[![forks](https://img.shields.io/github/forks/TeaEntityLab/rustLuaActor.svg?style=social\u0026label=Fork)](https://github.com/TeaEntityLab/rustLuaActor)\n\nLua Actor implementation for Rust (in sync/async modes)\n\n# Why\n\nI love Lua scripting; however it's hard to communicate between Lua \u0026 Rust, specially in some async scenarios.\n\nThus I implemented rustLuaActor. I hope you would like it :)\n\n# Features\n\n* Actor (*`lua_actor::actor`*)\n  * An Lua actor (sync/async)\n  * You could run it on the specific handler (*`fp_rust::handler::HandlerThread`*)\n\n# Dependencies\n\n* [fp_rust](https://crates.io/crates/fp_rust)\n* [rlua](https://crates.io/crates/rlua)\n\n# Setup\n\n*`Cargo.toml`*:\n\n```\nfp_rust=\"*\"\nrlua=\"*\"\nlua_actor=\"*\"\n```\n\n# Contribution\n\nSpecial Thanks to [poga's actix-lua](https://github.com/poga/actix-lua).\n\nMost of *`LuaMessage`* parts are coded by him (except `Array` \u0026 reverse conversions).\n\n# Usage\n\n## Actor (sync/async)\n\nExample:\n```rust\n\nextern crate rlua;\nextern crate fp_rust;\nextern crate lua_actor;\n\nfn main() {\n\n  use rlua::{Variadic};\n  use lua_actor::{actor::Actor, message::LuaMessage};\n\n\n  fn test_actor(act: Actor) {\n      let _ = act.exec_nowait(\n          r#\"\n          i = 1\n      \"#,\n          None,\n      );\n      assert_eq!(Some(1), Option::from(act.get_global(\"i\").ok().unwrap()));\n\n      let v = act.eval(\n          r#\"\n          3\n      \"#,\n          None,\n      );\n      assert_eq!(Some(3), Option::from(v.ok().unwrap()));\n\n      act.exec(\n          r#\"\n          function testit (i)\n              return i + 1\n          end\n      \"#,\n          None,\n      ).ok().unwrap();\n      match act.call(\"testit\", LuaMessage::from(1)) {\n          Ok(_v) =\u003e {\n              assert_eq!(Some(2), Option::from(_v));\n          }\n          Err(_err) =\u003e {\n              println!(\"{:?}\", _err);\n              panic!(_err);\n          }\n      }\n\n      {\n          act.def_fn_with_name_nowait(|_, (list1, list2): (Vec\u003cString\u003e, Vec\u003cString\u003e)| {\n              // This function just checks whether two string lists are equal, and in an inefficient way.\n              // Lua callbacks return `rlua::Result`, an Ok value is a normal return, and an Err return\n              // turns into a Lua 'error'.  Again, any type that is convertible to lua may be returned.\n              Ok(list1 == list2)\n          }, \"check_equal\").ok().unwrap();\n          act.def_fn_with_name_nowait(\n              |_, strings: Variadic\u003cString\u003e| {\n                  // (This is quadratic!, it's just an example!)\n                  Ok(strings.iter().fold(\"\".to_owned(), |a, b| a + b))\n              },\n              \"join\",\n          ).ok()\n          .unwrap();\n          assert_eq!(\n              Option::\u003cbool\u003e::from(\n                  act.eval(r#\"check_equal({\"a\", \"b\", \"c\"}, {\"a\", \"b\", \"c\"})\"#, None)\n                      .ok()\n                      .unwrap()\n              ).unwrap(),\n              true\n          );\n          assert_eq!(\n              Option::\u003cbool\u003e::from(\n                  act.eval(r#\"check_equal({\"a\", \"b\", \"c\"}, {\"d\", \"e\", \"f\"})\"#, None)\n                      .ok()\n                      .unwrap()\n              ).unwrap(),\n              false\n          );\n          assert_eq!(\n              Option::\u003cString\u003e::from(act.eval(r#\"join(\"a\", \"b\", \"c\")\"#, None).ok().unwrap())\n                  .unwrap(),\n              \"abc\"\n          );\n      }\n\n      act.set_global(\n          \"arr1\",\n          LuaMessage::from(vec![LuaMessage::from(1), LuaMessage::from(2)]),\n      ).ok()\n      .unwrap();\n\n      let v = Option::\u003cVec\u003cLuaMessage\u003e\u003e::from(act.get_global(\"arr1\").ok().unwrap());\n      assert_eq!(LuaMessage::from(1), v.clone().unwrap()[0]);\n      assert_eq!(LuaMessage::from(2), v.clone().unwrap()[1]);\n      assert_eq!(2, v.clone().unwrap().len());\n  }\n\n  let _ = test_actor(Actor::new_with_handler(None));\n  let _ = test_actor(Actor::new());\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteaentitylab%2Frustluaactor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteaentitylab%2Frustluaactor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteaentitylab%2Frustluaactor/lists"}