Installation
Prerequisites
Rust Version Requirements
rsbinder requires Rust 1.85 or later. Ensure you have the latest stable Rust toolchain:
$ rustup update stable
$ rustc --version # Should be 1.85+
Enable binder for Linux
Please refer to Enable binder for Linux for detailed instructions on setting it up.
Create binder device file for Linux
After the binder configuration of the Linux kernel is complete, a binder device file must be created.
Method 1: Install from crates.io
Install rsbinder-tools and run to create a binder device:
$ cargo install rsbinder-tools
$ sudo rsb_device binder
Method 2: Build from source
If you prefer to build from source:
$ git clone https://github.com/hiking90/rsbinder.git
$ cd rsbinder
$ cargo build --release
$ sudo target/release/rsb_device binder
The rsb_device tool will:
- Create
/dev/binderfsdirectory if it doesn't exist - Mount binderfs filesystem
- Create the specified binder device
- Set appropriate permissions (0666) for user access
Run a service manager for Linux
If rsbinder-tools is already installed, the rsb_hub executable is also installed. Run it as follows:
$ rsb_hub
Alternatively, if building from source:
$ cargo run --bin rsb_hub
The service manager (rsb_hub) provides:
- Service registration and discovery
- Service lifecycle management
- Priority-based service access
Using a custom binder device path
By default, rsb_hub uses /dev/binderfs/binder. If you created a binder device with a different name, use the --device (-d) option:
$ rsb_hub --device custom_binder
# or
$ rsb_hub -d custom_binder
In your Rust code, use ProcessState::init() instead of ProcessState::init_default() to specify the matching path:
#![allow(unused)] fn main() { // Use a custom binder device path ProcessState::init("/dev/binderfs/custom_binder", 0); }
Important: The service manager, service, and client must all use the same binder device path.
Dependencies for rsbinder projects
Add the following configuration to your Cargo.toml file:
[dependencies]
rsbinder = "0.5"
async-trait = "0.1"
env_logger = "0.11" # Optional: for logging
[build-dependencies]
rsbinder-aidl = "0.5"
Feature Flags
rsbinder supports various feature flags for different use cases:
[dependencies]
rsbinder = "0.5" # Default: includes tokio async runtime
# or
rsbinder = { version = "0.5", features = ["async"] } # Async trait support without tokio — use your own async runtime
# or
rsbinder = { version = "0.5", default-features = false } # Synchronous only (no async support)
Available features:
tokio(default): Full tokio async runtime support (includesasyncfeature)async: Async trait support without tokio runtime — use this when integrating with a different async runtimeandroid_*: Android version compatibility flags (see Android Development)
Crate Purposes:
- rsbinder: Core library providing Binder IPC functionality, including kernel communication, data serialization/deserialization, thread pool management, and service lifecycle.
- async-trait: Required for async interface implementations generated by rsbinder-aidl.
- rsbinder-aidl: AIDL-to-Rust code generator, used in build.rs for compile-time code generation.
- env_logger: Optional but recommended for debugging and development logging.