4 releases
Uses new Rust 2024
| new 0.1.3 | Feb 23, 2026 |
|---|---|
| 0.1.2 | Jan 13, 2026 |
| 0.1.1 | Jan 5, 2026 |
| 0.1.0 | Jan 5, 2026 |
#172 in FFI
28KB
484 lines
BridgeRust
Write Rust once, deploy to Python and Node.js.
BridgeRust is a unified framework for building cross-language Rust libraries. It eliminates the complexity of managing separate bindings for PyO3 (Python) and napi-rs (Node.js) by providing a single, unified macro system.
Website: bridgerust.dev
🚀 Features
- Unified Logic: One
#[bridgerust::export]macro handles both Python and Node.js generation. - Zero Config: No need to manually configure PyO3 or napi-rs builds.
- Type Safety: Automatic type mapping between Rust, Python, and TypeScript.
🎯 Best Use Cases
BridgeRust is currently SDK-Ready and ideal for:
- Unified SDKs / Clients: Perfect for database drivers (like Embex) or API clients. Seamlessly handles
async/awaitand complex JSON objects. - CPU-Intensive Data Processing: Expose high-performance Rust logic (parsers, encryption, image processing) to interpreted languages with minimal overhead.
- Shared Logic Cores: Write business validation rules once in Rust structs/enums and reuse them across your Node.js backend and Python data pipelines.
📦 Usage
Add to your Cargo.toml:
[dependencies]
bridgerust = "0.1"
Annotate your Rust functions:
use bridgerust::export;
#[export]
pub fn greet(name: String) -> String {
format!("Hello, {}!", name)
}
🏗️ Building
BridgeRust creates standard Python wheels and Node.js native modules.
Using the CLI (Recommended)
# Install the CLI
cargo install --path cli/bridge
# Initialize a new project
bridge new my-project
# Development (Live Reload)
bridge dev
# Build for all targets
bridge build --all
# Run tests
bridge test --all
# Run benchmarks
bridge benchmark
# Publish packages
bridge publish --all
Manual Building
# Build for Python
cargo build --features python
# Build for Node.js
cargo build --features nodejs
📚 Documentation
- Quick Reference - Cheat sheet for common patterns
- Getting Started Guide - Complete tutorial
- Migration Guide - Migrate from PyO3/napi-rs
- Examples - Code examples and patterns
- Troubleshooting - Common issues and solutions
- CLI Documentation - CLI tool reference
- E2E Test Examples - Integration test examples
🎯 Quick Example
use bridgerust::export;
#[export]
pub fn greet(name: String) -> String {
format!("Hello, {}!", name)
}
#[export]
pub struct Point {
pub x: f64,
pub y: f64,
}
Build and use from both Python and Node.js with a single command!
Dependencies
~1.2–4MB
~75K SLoC