ferrocarril aims to embed a Ruby on Rails web application that talks to an external MySQL database in Rust and serve the app with Rocket.
ferrocarril means railway in Spanish and sounds like ferrous which means containing iron.
The foolsgold crate is an early attempt to achieve the goal of a Rust-backed Ruby web application.
cargo run --bin foolsgold
Then, open http://localhost:8000
on your browser.
- Embeds a safe interpreter that wraps generated C bindings for mruby.
- Implements a web application server similar to Thin that supports shared nothing and prefork execution modes.
- Loads pure Ruby sources into the interpreter's virtual filesystem such that Ruby code can require them.
- Defines classes and modules in Rust and loads them into the virtual filesystem such that Ruby code can require them.
- Shares Rust objects across mruby interpreter instances.
- Defines Ruby classes whose instances are backed by Rust structs.
- Bridges Rust and Ruby by converting a Rack-compatible response into a Rocket response.
Crate mruby-bin provides an rirb
executable that is an
IRB shell and REPL for
the mruby interpreter in this workspace. rirb
aims to load every
extension to mruby made by this workspace in addition to all gems in
the gems crate.
cargo run --bin rirb
There is a lot to build! If you'd like to help out, take a look at the open issues. Tickets that are tagged with good first issue might be a good introduction to the codebase.
To familiarize yourself with the code in this workspace, consider reviewing these source files:
File | Purpose | Learning Objective |
---|---|---|
manual.rs | mruby crate integration test | Define Rust-backed Ruby sources |
nemesis.rs | nemesis crate Ruby runtime | Define a Gem |
ffi_tests.rs | C API test suite | Manipulate an interpreter with the C API |
repl.rs | REPL loop for rirb |
Eval code on an interpreter and handle errors |
mruby does not implement all Ruby 2.6 core classes.
Required classes include (at least):
File
IO
Regexp
mruby does not implement any of the Ruby 2.6 standard library.
Required packages include (at least):
forwardable
json
set
stringio
time
uri
zlib
Rails requires lots of gems. This workspace maintains a registry of vendored gems. To support the goal of running Rails, this crate identifies dependencies, vendors the gem sources, patches gems so they parse on mruby, reimplements C extensions in Rust, and runs the tests for each gem.