Expand description
§mtp-rs
A pure-Rust MTP (Media Transfer Protocol) library targeting modern Android devices.
§Features
- Runtime agnostic: Uses
futurestraits, works with any async runtime - Two-level API: High-level
mtp::for media devices, low-levelptp::for cameras - Streaming: Memory-efficient streaming downloads with progress tracking
- Type safe: Newtype wrappers prevent mixing up IDs
§Quick start
ⓘ
use mtp_rs::mtp::MtpDevice;
// Open the first MTP device
let device = MtpDevice::open_first().await?;
println!("Connected to: {} {}",
device.device_info().manufacturer,
device.device_info().model);
// Get storages
for storage in device.storages().await? {
println!("Storage: {} ({} free)",
storage.info().description,
storage.info().free_space_bytes);
// List root folder
for obj in storage.list_objects(None).await? {
let kind = if obj.is_folder() { "DIR " } else { "FILE" };
println!(" {} {} ({} bytes)", kind, obj.filename, obj.size);
}
}Re-exports§
pub use error::Error;pub use ptp::receive_stream_to_stream;pub use ptp::DateTime;pub use ptp::EventCode;pub use ptp::ObjectFormatCode;pub use ptp::ObjectHandle;pub use ptp::OperationCode;pub use ptp::ReceiveStream;pub use ptp::ResponseCode;pub use ptp::SessionId;pub use ptp::StorageId;pub use ptp::TransactionId;pub use mtp::DeviceEvent;pub use mtp::FileDownload;pub use mtp::MtpDevice;pub use mtp::MtpDeviceBuilder;pub use mtp::NewObjectInfo;pub use mtp::ObjectListing;pub use mtp::Progress;pub use mtp::Storage;