[−][src]Struct libmtp_rs::storage::Storage
Storage descriptor of some MTP device, note that updating the storage and keeping a old copy of this struct is impossible.
Implementations
impl<'a> Storage<'a>[src]
pub fn id(&self) -> u32[src]
Retrieves the id of this storage.
pub fn format_storage(&self) -> Result<()>[src]
Formats this storage (if its device supports the operation).
WARNING: This WILL DELETE ALL DATA from the device, make sure you've got confirmation from the user before calling this function.
pub fn files_and_folders(&self, parent: Parent) -> Vec<File<'a>>[src]
Retrieves the contents of a certain folder (parent) in this storage, the result contains
both files and folders, note that this request will always perform I/O with the device.
pub fn get_file_to_path<C>(
&self,
file: impl AsObjectId,
path: impl AsRef<Path>,
callback: Option<C>
) -> Result<()> where
C: FnMut(u64, u64) -> bool, [src]
&self,
file: impl AsObjectId,
path: impl AsRef<Path>,
callback: Option<C>
) -> Result<()> where
C: FnMut(u64, u64) -> bool,
Retrieves a file from the device storage to a local file identified by a filename.
The callback parameter is an optional progress function with the following signature
(sent_bytes: u64, total_bytes: u64) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
pub fn get_file_to_descriptor<C>(
&self,
file: impl AsObjectId,
descriptor: impl AsRawFd,
callback: Option<C>
) -> Result<()> where
C: FnMut(u64, u64) -> bool, [src]
&self,
file: impl AsObjectId,
descriptor: impl AsRawFd,
callback: Option<C>
) -> Result<()> where
C: FnMut(u64, u64) -> bool,
Retrieves a file from the device storage to a local file identified by a descriptor.
The callback parameter is an optional progress function with the following signature
(sent_bytes: u64, total_bytes: u64) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
pub fn get_file_to_handler<H, C>(
&self,
file: impl AsObjectId,
handler: H,
callback: Option<C>
) -> Result<()> where
H: FnMut(&[u8], &mut u32) -> HandlerReturn,
C: FnMut(u64, u64) -> bool, [src]
&self,
file: impl AsObjectId,
handler: H,
callback: Option<C>
) -> Result<()> where
H: FnMut(&[u8], &mut u32) -> HandlerReturn,
C: FnMut(u64, u64) -> bool,
Retrieves a file from the device storage and calls handler with chunks of data.
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) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
pub fn send_file_from_path<C>(
&self,
path: impl AsRef<Path>,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
C: FnMut(u64, u64) -> bool, [src]
&self,
path: impl AsRef<Path>,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
C: FnMut(u64, u64) -> bool,
Sends a local file to the MTP device who this storage belongs to.
The callback parameter is an optional progress function with the following signature
(sent_bytes: u64, total_bytes: u64) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
pub fn send_file_from_descriptor<C>(
&self,
descriptor: impl AsRawFd,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
C: FnMut(u64, u64) -> bool, [src]
&self,
descriptor: impl AsRawFd,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
C: FnMut(u64, u64) -> bool,
Sends a local file via descriptor to the MTP device who this storage belongs to.
The callback parameter is an optional progress function with the following signature
(sent_bytes: u64, total_bytes: u64) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
pub fn send_file_from_handler<H, C>(
&self,
handler: H,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
H: FnMut(&mut [u8], &mut u32) -> HandlerReturn,
C: FnMut(u64, u64) -> bool, [src]
&self,
handler: H,
parent: Parent,
metadata: FileMetadata<'_>,
callback: Option<C>
) -> Result<File<'a>> where
H: FnMut(&mut [u8], &mut u32) -> HandlerReturn,
C: FnMut(u64, u64) -> bool,
Sends a bunch of data to the MTP device who this storage belongs to.
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) -> bool, this way you can check the progress and
if you want to cancel operation you just return false.
Auto Trait Implementations
impl<'a> RefUnwindSafe for Storage<'a>
impl<'a> !Send for Storage<'a>
impl<'a> !Sync for Storage<'a>
impl<'a> Unpin for Storage<'a>
impl<'a> UnwindSafe for Storage<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,