Rust Crates
RBS provides two Rust crates:
ruby-rbs-sys-- Low-level FFI bindings to theRBSC parserruby-rbs-- High-level safe Rust API for parsingRBSsignatures
Both crates are published to crates.io and are developed within the rust/ directory of this repository.
Vendored RBS Source
The Rust crates depend on the RBS C parser source code (include/, src/) and configuration (config.yml) from this repository. These files are vendored into each crate's vendor/rbs/ directory, which is managed by Rake tasks and not tracked by git.
The file rust/rbs_version records which version of RBS the Rust crates are pinned to.
Setup
After cloning the repository, set up the vendored source before building the Rust crates:
rake rust:rbs:sync # Uses the pinned version from rust/rbs_version
Then build and test:
cd rust
cargo test
Rake Tasks
rake rust:rbs:sync
Copies the source files from the pinned version into each crate's vendor/rbs/. The copied files are made read-only to prevent accidental edits.
rake rust:rbs:pin
Records a git tag in rust/rbs_version. For example:
rake rust:rbs:pin[v4.0.3]
rake rust:publish:ruby-rbs-sys / rake rust:publish:ruby-rbs
Publishes each crate to crates.io individually. Each task:
- Verifies
rust/rbs_versionis set - Verifies vendor directories contain real files (not symlinks)
- Verifies the git working tree is clean
- Creates a release branch and commits the vendor files
- Runs a dry-run to check packaging
- Publishes the crate
Set RBS_RUST_PUBLISH_DRY_RUN=1 to only run the dry-run step and skip the actual publish to crates.io. This is used in CI to verify that the crates can be packaged correctly.
rake rust:rbs:symlink
If your development needs unreleased version of RBS source code, use rake rust:rbs:symlink to set up symlinks in vendor directories to refer the worktree source code. Changes to the C parser source are immediately reflected in Rust builds.
Publishing Workflow
-
Pin the RBS version to release against:
rake rust:rbs:pin[v4.0.3] -
Sync the vendored source:
rake rust:rbs:sync -
Update crate versions in
rust/ruby-rbs-sys/Cargo.tomlandrust/ruby-rbs/Cargo.toml. -
Build and test:
cd rust && cargo test -
Commit the version changes and
rust/rbs_version:git add rust/rbs_version rust/ruby-rbs-sys/Cargo.toml rust/ruby-rbs/Cargo.toml git commit -m "Bump Rust crate versions" -
Publish each crate:
rake rust:publish:ruby-rbs-sys rake rust:publish:ruby-rbs