Installation
Prerequisites
Rust Version Requirements
rsbinder requires Rust 1.77 or later. Ensure you have the latest stable Rust toolchain:
$ rustup update stable
$ rustc --version # Should be 1.77+
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/binderfs
directory 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
- Service health monitoring
Dependencies for rsbinder projects
Add the following configuration to your Cargo.toml file:
[dependencies]
rsbinder = "0.4.0"
lazy_static = "1"
async-trait = "0.1"
env_logger = "0.11" # Optional: for logging
[build-dependencies]
rsbinder-aidl = "0.4.0"
Feature Flags
rsbinder supports various feature flags for different use cases:
[dependencies]
rsbinder = { version = "0.4.0", features = ["tokio"] } # Default: includes tokio
# or
rsbinder = { version = "0.4.0", features = ["sync"] } # Sync-only version
# or
rsbinder = { version = "0.4.0", features = ["async"] } # Async without tokio
Available features:
tokio
(default): Full tokio async runtime supportsync
: Synchronous-only operationsasync
: Async support without tokio runtimeandroid_*
: Android version compatibility flags
Crate Purposes:
- rsbinder: Core library providing Binder IPC functionality, including kernel communication, data serialization/deserialization, thread pool management, and service lifecycle.
- lazy_static: Required by generated AIDL code for static initialization of interface descriptors and transaction codes.
- 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.