Loading repository data…
Loading repository data…
xberg-io / repository
Generate fully-typed, lint-clean language bindings for Rust libraries across 16 languages
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Alef is the polyglot binding generator behind the Xberg.dev ecosystem. It extracts a Rust API surface
and emits language-native bindings, package scaffolding, type stubs, README files, API docs, e2e
tests, and release metadata from one alef.toml.
Installation | Quick Start | Supported Targets | CLI Reference
Extension trait; ship as linked binaries, dynamic libraries, or template-only declarations.Alef requires Rust 1.85 or newer.
cargo install alef --locked
If you use cargo-binstall, Alef also publishes
binary-install metadata:
cargo binstall alef
Create or edit alef.toml in your Rust workspace:
[workspace]
languages = ["python", "node", "ffi", "go"]
alef_version = "0.24.12"
[[crates]]
name = "sample_core"
sources = ["src/lib.rs"]
version_from = "Cargo.toml"
Then generate the language packages:
alef generate --format
alef scaffold
alef readme
alef docs --output docs/reference
alef verify --exit-code
For a new project, Alef can create the initial config and first generated files:
alef init --lang python,node,ffi
For the full local generation pass, use:
alef all --format
Use --lang python,node to restrict commands to selected targets and --crate <name> to restrict
commands to one configured crate.
| Target | Backend / package style |
|---|---|
| Python | PyO3 bindings with Python type stubs |
| TypeScript / Node.js | NAPI-RS native addon with .d.ts output |
| WebAssembly | wasm-bindgen package for browser and JS runtimes |
| Ruby | Magnus native extension |
| PHP | Native PHP extension |
| Elixir | Rustler NIF package |
| R | extendr package |
| Go | cgo package over the generated C FFI layer |
| Java | JVM package over the generated native library |
| Kotlin | Kotlin/JVM package over generated native bindings |
| Kotlin Android | Android package with generated JNI shims |
| C# | .NET package using P/Invoke |
| Dart / Flutter | flutter_rust_bridge package |
| Swift | Swift package with Rust bridge support |
| Zig | Zig package over the generated C ABI |
| Gleam | Gleam package backed by Rustler |
| C FFI | C ABI, header, and shared-library glue |
| JNI | Rust JNI shim crate exercised by both kotlin_android (Android AAR) and host-JVM tests |
Canonical language slugs are python, node, wasm, ruby, php, elixir, r, go,
java, csharp, kotlin, kotlin_android, swift, dart, gleam, zig, ffi, and jni.
Alef uses the current multi-crate schema:
[workspace] stores shared target languages, tool preferences, and pipeline defaults.[[crates]] describes each Rust API surface that should become one or more published packages.[crates.<language>] sections customize module names, package names, feature flags, output paths,
field naming, dependency extras, and language-specific generation behavior.[[crates.adapters]], trait bridge config, service API config, and e2e config opt into higher-level
generated wrappers when a target supports them.Generated binding files carry Alef hashes and are overwritten by generation commands. Scaffolded
package files are generated once unless the command explicitly opts into overwrite behavior; generated
README and API doc files are owned by alef readme and alef docs.
Alef is opinionated about codegen and neutral about domain. The Extension trait lets you ship domain-specific generation logic (HTTP service APIs, plugin registries, custom bindings) without bloat in alef.
Consumer crate implements alef::Extension, ships a thin CLI binary:
fn main() {
alef::run_with_extensions(vec![Box::new(MyDomainExtension)])
}
Full type safety. Recommended for frameworks that generate an HTTP service API.
Load a compiled .so/.dylib/.dll declaring a C-ABI factory function. Works when you can't ship a Rust binary.
[[extensions.dylib]]
path = "target/release/libmy_extension.dylib"
extern "C" fn alef_extension_factory() -> Box<dyn alef::Extension> {
Box::new(MyExtension)
}
Declare [[extensions.template]] blocks in alef.toml pointing to Jinja templates. Alef's built-in TemplateExtension emits them — no Rust required.
The full extension walkthrough covers trait references and per-language emission patterns.
| Command | Purpose |
|---|---|
alef init | Create alef.toml, generate initial bindings, and scaffold package files. |
alef extract | Extract Rust source into Alef IR JSON. |
alef generate | Generate bindings, service API wrappers, public API wrappers, and type stubs. |
alef stubs | Generate type stubs only. |
alef scaffold | Generate package manifests, native build files, and package scaffolding. |
alef readme | Generate per-language README files. |
alef docs | Generate Markdown API reference pages. |
alef setup | Install per-language development dependencies. |
alef fmt / alef lint | Run configured formatters, linters, and type checks. |
alef test | Run configured unit, integration, e2e, or coverage test commands. |
alef build | Build language bindings using native tools. |
alef verify | Check generated files and optional compile/lint state for CI. |
alef diff | Show what generation would change without writing files. |
alef e2e | Initialize, scaffold, validate, list, or generate local e2e suites. |
alef test-apps | Generate and run standalone registry-mode test applications. |
alef publish | Prepare, build, package, and validate release artifacts. |
alef all | Run the full generation workflow in one command. |
Run alef --help or alef <command> --help for the full option set.
This repository uses task for common workflows:
task setup
task build
task test
task lint
The most useful targeted commands while working on Alef itself are:
cargo test <module_or_test_name>
cargo insta review
prek run --all-files
MIT - see LICENSE for details.