{"id":13437894,"url":"https://github.com/anima-engine/mrusty","last_synced_at":"2025-04-05T06:09:10.277Z","repository":{"id":47603169,"uuid":"51146396","full_name":"anima-engine/mrusty","owner":"anima-engine","description":"mruby safe bindings for Rust","archived":false,"fork":false,"pushed_at":"2021-08-13T12:32:59.000Z","size":612,"stargazers_count":205,"open_issues_count":13,"forks_count":19,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-29T05:08:51.720Z","etag":null,"topics":["bridge","mruby","ruby","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anima-engine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-02-05T12:55:22.000Z","updated_at":"2024-11-26T05:26:38.000Z","dependencies_parsed_at":"2022-09-11T18:11:43.178Z","dependency_job_id":null,"html_url":"https://github.com/anima-engine/mrusty","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anima-engine%2Fmrusty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anima-engine%2Fmrusty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anima-engine%2Fmrusty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anima-engine%2Fmrusty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anima-engine","download_url":"https://codeload.github.com/anima-engine/mrusty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294539,"owners_count":20915340,"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":["bridge","mruby","ruby","rust"],"created_at":"2024-07-31T03:01:01.020Z","updated_at":"2025-04-05T06:09:10.261Z","avatar_url":"https://github.com/anima-engine.png","language":"Rust","readme":"# mrusty. mruby safe bindings for Rust\n[![Build Status](https://travis-ci.org/anima-engine/mrusty.svg?branch=master)](https://travis-ci.org/anima-engine/mrusty)\n[![Coverage Status](https://coveralls.io/repos/github/anima-engine/mrusty/badge.svg?branch=master)](https://coveralls.io/github/anima-engine/mrusty?branch=master)\n[![Cargo Crate](http://meritbadge.herokuapp.com/mrusty)](https://crates.io/crates/mrusty)\n\nmrusty lets you:\n\n* run Ruby 1.9 files with a very restricted API (without having to install Ruby)\n* reflect Rust `struct`s and `enum`s in mruby and run them\n\nIt does all this in a safely neat way, while also bringing spec testing and a\nREPL to the table.\n\n## [Documentation](http://anima-engine.github.io/mrusty/)\n\n## Example\nA very simple example of a Container `struct` which will be passed to mruby and\nwhich is perfectly callable.\n```rust\n// mrusty_class!\n#[macro_use]\nextern crate mrusty;\n\nuse mrusty::{Mruby, MrubyImpl};\n\nlet mruby = Mruby::new();\n\nstruct Cont {\n    value: i32\n}\n\n// Cont should not flood the current namespace. We will add it with require.\nmrusty_class!(Cont, \"Container\", {\n    // Converts mruby types automatically \u0026 safely.\n    def!(\"initialize\", |v: i32| {\n        Cont { value: v }\n    });\n\n    // Converts slf to Cont.\n    def!(\"value\", |mruby, slf: (\u0026Cont)| {\n        mruby.fixnum(slf.value)\n    });\n});\n\n// Add file to the context, making it requirable.\nmruby.def_file::\u003cCont\u003e(\"cont\");\n\n// Add spec testing.\ndescribe!(Cont, \"\n  context 'when containing 1' do\n    it 'returns 1 when calling #value' do\n      expect(Container.new(1).value).to eql 1\n    end\n  end\n\");\n\nlet result = mruby.run(\"\n  require 'cont'\n\n  Container.new(3).value\n\").unwrap(); // Returns Value.\n\nprintln!(\"{}\", result.to_i32().unwrap()); // Prints \"3\".\n```\n","funding_links":[],"categories":["Development tools","开发工具 Development tools","开发工具"],"sub_categories":["FFI","FFI FFI","示例 FFI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanima-engine%2Fmrusty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanima-engine%2Fmrusty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanima-engine%2Fmrusty/lists"}