[][src]Struct libmtp_rs::storage::StoragePool

pub struct StoragePool<'a> { /* fields omitted */ }

Represents all the storage "pool" of one MTP device, contain all the storage entries of one MTP device, and contains some methods to send or get files from the primary storage.

Implementations

impl<'a> StoragePool<'a>[src]

pub fn by_id(&self, id: u32) -> Option<&Storage<'a>>[src]

Returns the storage that has the given id, if there's one.

pub fn iter(&'a self) -> StoragePoolIter<'a>

Notable traits for StoragePoolIter<'a>

impl<'a> Iterator for StoragePoolIter<'a> type Item = (u32, &'a Storage<'a>);
[src]

Returns an iterator over the storages, this is a HashMap iterator.

pub fn files_and_folders(&self, parent: Parent) -> Vec<File<'a>>[src]

Retrieves the contents of a certain folder (parent) in all storages, the result contains both files and folders, note that this request will always perform I/O with the device.

pub fn folder_list(&self) -> Option<Folder<'_>>[src]

Optionally returns a Folder, with this struct you can build a tree structure (see Folder for more info)

pub fn create_folder<'b>(
    &self,
    name: &'b str,
    parent: Parent
) -> Result<(u32, Cow<'b, str>)>
[src]

Tries to create a new folder in the default storage of the relevant MtpDevice, returns the id of the new folder and its name, note that the name may be different due to device file system restrictions.

pub fn get_file_to_path<C>(
    &self,
    file: impl AsObjectId,
    path: impl AsRef<Path>,
    callback: impl Into<Option<C>>
) -> Result<()> where
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Retrieves a file from the device storage to a local file identified by a filename, note that this is just a convenience method since it's not necessary to depend on the Storage, this is because objects have unique ids across all the device.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

pub fn get_file_to_descriptor<C>(
    &self,
    file: impl AsObjectId,
    descriptor: impl AsRawFd,
    callback: impl Into<Option<C>>
) -> Result<()> where
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Retrieves a file from the device storage to a local file identified by a descriptor, note that this is just a convenience method since it's not necessary to depend on the Storage, this is because objects have unique ids across all the device.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

pub fn get_file_to_handler<H, C>(
    &self,
    file: impl AsObjectId,
    handler: H,
    callback: impl Into<Option<C>>
) -> Result<()> where
    H: FnMut(&[u8], &mut u32) -> HandlerReturn,
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Retrieves a file from the device storage and calls handler with chunks of data, note that this is just a convenience method since it's not necessary to depend on the Storage, this is because objects have unique ids across all the device.

The handler parameter is the function that receives the chunks of data with the following signature (data: &[u8], read_len: &mut u32) -> HandlerReturn, where the read_len should be modified with the amount of bytes you actually read, the HandlerReturn allows you to specify if the operation was ok, had an error or if you want to cancel it.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

pub fn send_file_from_path<C>(
    &self,
    path: impl AsRef<Path>,
    parent: Parent,
    metadata: FileMetadata<'_>,
    callback: impl Into<Option<C>>
) -> Result<File<'a>> where
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Sends a local file to the MTP device who this storage belongs to, note that this method will send the file to the primary storage.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

pub fn send_file_from_descriptor<C>(
    &self,
    descriptor: impl AsRawFd,
    parent: Parent,
    metadata: FileMetadata<'_>,
    callback: impl Into<Option<C>>
) -> Result<File<'a>> where
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Sends a local file via descriptor to the MTP device who this storage belongs to, note that this method will send the file to the primary storage.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

pub fn send_file_from_handler<H, C>(
    &self,
    handler: H,
    parent: Parent,
    metadata: FileMetadata<'_>,
    callback: impl Into<Option<C>>
) -> Result<File<'a>> where
    H: FnMut(&mut [u8], &mut u32) -> HandlerReturn,
    C: FnMut(u64, u64) -> CallbackReturn
[src]

Sends a bunch of data to the MTP device who this storage belongs to, note that this method will send the file to primary storage.

The handler parameter is the function that receives the chunks of data with the following signature (data: &mut [u8], write_len: &mut u32) -> HandlerReturn, where the write_len should be modified with the amount of bytes you actually write, the HandlerReturn allows you to specify if the operation was ok, had an error or if you want to cancel it.

The callback parameter is an optional progress function with the following signature (sent_bytes: u64, total_bytes: u64) -> CallbackReturn, this way you can check the progress and if you want to cancel operation you just return CallbackReturn::Cancel.

Trait Implementations

impl<'a> Debug for StoragePool<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for StoragePool<'a>

impl<'a> !Send for StoragePool<'a>

impl<'a> !Sync for StoragePool<'a>

impl<'a> Unpin for StoragePool<'a>

impl<'a> UnwindSafe for StoragePool<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.