Overview
Welcome to rsbinder!
rsbinder is a Rust library and toolset that enables you to utilize Binder IPC on Linux and Android OS. It provides pure Rust implementations that make Binder IPC available across both platforms.
Binder IPC is an object-oriented IPC (Inter-Process Communication) mechanism that Google added to the Linux kernel for Android. Android uses Binder IPC for all process communication, and the binder driver has been part of the mainline Linux kernel since version 4.17 (with the binderfs filesystem rsbinder uses arriving in 5.0).
However, since it is rarely used outside of Android, it is disabled by default in most Linux distributions, so you typically need a kernel built with binder support to use the kernel-binder path (see Enable binder for Linux).
rsbinder ships two parallel stacks:
- The traditional kernel binder path through
/dev/binder//dev/binderfs/binder, which most of this guide covers. - An RPC transport (binder-over-socket) — AOSP's
RpcServer/RpcSessionanalogue, pure user-space, no kernel driver. Drives the same generated AIDL stubs over Unix-domain sockets, vsock, or TLS, and runs on Linux, Android, and macOS. See RPC Transport.
Crates
rsbinder offers the following crates:
rsbinder: Core library crate for implementing binder service/client functionality.rsbinder-aidl: AIDL-to-Rust code generator for rsbinder.rsbinder-macros: The same generator, reached from a Rust trait instead of an.aidlfile. Not a direct dependency — enablersbinder'smacrosfeature. See Interface Macros.rsbinder-tools: CLI tools — the Binder Service Manager for Linux (rsb_hub), the device setup helper (rsb_device), and the registry inspector (rsb_service).tests: Port of Android's binder test cases for client/server testing.example-hello: Example service/client implementation using rsbinder.
Key Features
- Object-oriented: a call is a method call on a remote object, with strong and weak references that work across processes — not a message you frame yourself.
- Wire-compatible with Android: the same protocol as
libbinder, so an rsbinder client can call a service written in C++ or Java, and the other way round. - Two transport stacks: kernel binder for on-device IPC, and an opt-in RPC transport (Unix sockets, vsock, or TLS) for cross-process, cross-VM, or cross-host calls — both driven by the same AIDL-generated code.
- Cross-platform: Linux and Android (kernel binder), plus macOS (RPC transport only).
- Async/Sync: both programming models, with optional tokio integration.
Core Components
- Parcel: Data serialization and deserialization for IPC transactions
- Binder Objects: Strong and weak references for cross-process communication
- AIDL Compiler: Generates Rust code from Android Interface Definition Language files
- Service Manager: Centralized service discovery and registration (rsb_hub for Linux)
- Thread Pool: Efficient handling of concurrent IPC transactions
- Death Notification: Service lifecycle management and cleanup
- Shared Memory: Payloads too big to copy through a transaction (Shared Memory)
Resources
- API Documentation: docs.rs/rsbinder
- Repository: github.com/hiking90/rsbinder
Before using Binder IPC on Linux, you must enable the feature in the kernel. Please refer to Enable binder for Linux for detailed instructions. For Android, see Android Development.