rsbinder
rsbinder is a pure Rust implementation of Binder IPC for Linux, Android, and macOS.
It offers two transports behind the same AIDL interfaces:
- Kernel binder — the
/dev/binderdriver on Linux and Android, with the same protocol and wire format as Androidlibbinder, so rsbinder talks directly to existing Android services written in C++ or Java. - RPC transport — binder over Unix, vsock, or TLS sockets, with no kernel driver and no root. Wire-compatible with Android
libbinderRPC, verified against reallibbinderon Android 13–16.
If you'd rather use C++ on Linux, see binder-linux.
Crates
- rsbinder — the binder library: services, clients, parcels, async.
- rsbinder-aidl — AIDL → Rust code generator.
- rsbinder-macros —
#[rsbinder::interface]: declare an interface as a Rust trait, without.aidl. - rsbinder-fmq — Android's Fast Message Queue (
libfmq), independent of binder. - rsbinder-tools —
rsb_hub(service manager for Linux),rsb_device,rsb_service.
Features
- Kernel binder and RPC transport, chosen at run time by a
Uri(rsbinder::serve,rsbinder::connect). - AIDL compiler compatible with Android's, and interface macros that generate the same code.
- Sync and Tokio async APIs.
ParcelFileDescriptor, shared memory (IMemory), Fast Message Queue and streaming.- Storing AIDL values to bytes (
to_bytes/from_bytes). - Service manager for Linux (
rsb_hub) with access control and on-demand start.
Platform Support
| Platform | Kernel binder | RPC transport |
|---|---|---|
| Linux | ✅ (binderfs) | ✅ |
| Android | ✅ (10–17, API 29–37) | ✅ |
| macOS | — | ✅ |
Parcel data is little-endian on every host, as on Android.
Getting Started
RPC transport (no kernel config, no root):
$ cargo run -p example-hello --features rpc --bin rpc_hello_service
$ cargo run -p example-hello --features rpc --bin rpc_hello_client
Kernel binder needs binderfs (CONFIG_ANDROID_BINDERFS=y; Arch Linux linux-zen has it, for Ubuntu see Enable Binder on Ubuntu):
$ cargo build
$ sudo target/debug/rsb_device binder --group "$(id -gn)" --mode 0660
$ cargo run --bin rsb_hub -- --insecure-allow-all
$ cargo run --bin hello_service
$ cargo run --bin hello_client
Android: build with cargo-ndk for API 29 or newer:
$ cargo ndk -t aarch64-linux-android --platform 29 build --release
Documentation
The rsbinder book covers installation, AIDL, the RPC transport, Android compatibility and migration between releases. API reference is on docs.rs.
rsbinder is pre-1.0. Each public API is classified Stable, Provisional or Experimental; see Stability Tiers.
Contributing
See CONTRIBUTING.md.
License
Licensed under the Apache License, Version 2.0.
Notice
Many source files in rsbinder were developed by quoting or referencing Android's binder implementation.