Crate libmtp

Crate libmtp 

Source
Expand description

A memory safe API for interacting with libmtp library.

crates.io

§Install

To install the latest version of the crate from crates.io, run:

$ cargo add libmtp

§Getting started

To get started, create a new program that prints all objects in the root folder of your storage:

use libmtp::RawDevice;
use libmtp::search_raw_devices;

fn main() -> libmtp::Result<()> {
    for device in search_raw_devices()?.filter_map(RawDevice::open_uncached) {
        for storage in &device {
            for object in &storage {
                println!("{object:?}");
            }
        }
    }
    Ok(())
}

For more examples, see examples.

§Changelog

For a release history, see CHANGELOG.md.

§Contributing

For a contibuting guide, see CONTRIBUTING.md.

§License

This crate is distributed under the terms of MIT License.

See LICENSE for details.

Structs§

Battery
The battery of the device.
Device
An opened device connected via USB.
Error
Specialized Error type used within the crate.
File
A file on the storage.
Folder
A folder on the storage.
ObjectIter
An iterator over the objects of the folder.
ObjectRecursiveIter
A recursive iterator over the objects of the folder.
Product
A product of the device.
RawDevice
A device connected via USB, but not yet opened.
RawDeviceIter
An iterator over the raw devices.
Storage
A storage of the device.
StorageIter
An iterator over the storages of the device.
Vendor
A vendor of the device.

Enums§

ErrorKind
Category for an error used within the crate.
FileKind
The kind of the file.
Filesystem
A filesystem of the storage.
MtpErrorKind
Category for an error, that occured at the MTP (Media Transfer Protocol) layer.
Object
A file or a folder on the storage.
StorageAccess
An access capability over the storage.
StorageKind
A kind of the storage.

Functions§

search_raw_devices
Searches the devices connected via USB, but not yet opened.

Type Aliases§

Result
Specialized Result type used within the crate.