Announcing mtp-rs: pure-Rust MTP library, no C deps, up to 4x faster than libmtp
⚓ Rust 📅 2026-03-19 👤 surdeus 👁️ 2I built mtp-rs, a pure-Rust async MTP/PTP library. No libmtp, no libusb, no FFI. Built on nusb.
(Quick refresher: MTP is the protocol your phone uses when you plug it into a computer to copy files.)
It's 1.06–4.04x faster than libmtp across all operations I tested, and absurdly more consistent. At 100 MB downloads, mtp-rs std dev was 4.7 ms vs libmtp's 4,612 ms. (That's 1000x more consistent!)
See here:
| Operation | Size | mtp-rs | libmtp | Speedup |
|---|---|---|---|---|
| download | 1 MB | 33.9ms | 45.3ms | 1.34x |
| download | 10 MB | 258.3ms | 391.1ms | 1.51x |
| download | 100 MB | 2.447s | 9.897s | 4.04x |
| upload | 1 MB | 76.1ms | 115.0ms | 1.51x |
| upload | 10 MB | 326.9ms | 345.1ms | 1.06x |
| upload | 100 MB | 2.388s | 2.796s | 1.17x |
| list_files | - | 15.5ms | 24.9ms | 1.61x |
It has two API layers: mtp:: for Android phones and media devices, ptp:: for cameras and low-level protocol work.
Here is how to use the API:
use mtp_rs::mtp::MtpDevice;
let device = MtpDevice::open_first().await?;
for storage in device.storages().await? {
for file in storage.list_objects(None).await? {
println!("{} {}", if file.is_folder() { "📁" } else { "📄" }, file.filename);
}
}
I've tested it on a Pixel 9 Pro XL, Samsung Galaxy S23 Ultra, and a Fujifilm X-T4. It handles device quirks automatically (Android's broken recursive listing, Samsung's root listing errors, Fuji advertising write support it doesn't have).
I need community help testing with more devices. The test suite is designed so only read-only tests run by default, so it won't mess with your files. If you have an MTP device and 5 minutes:
Full writeup with benchmarks: Announcing mtp-rs: pure-Rust MTP library, up to 4x faster than libmtp | David Veszelovszki
1 post - 1 participant
🏷️ Rust_feed