pub struct Storage<'a> { /* private fields */ }Expand description
A storage of the device.
Implementations§
Source§impl<'a> Storage<'a>
impl<'a> Storage<'a>
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Retrieves the friendly name of the storage.
§Panics
Panics if the friendly name of the storage is not a valid UTF-8.
Sourcepub fn kind(&self) -> Option<StorageKind>
pub fn kind(&self) -> Option<StorageKind>
Retrieves the kind of the storage.
Sourcepub fn fs(&self) -> Option<Filesystem>
pub fn fs(&self) -> Option<Filesystem>
Retrieves the filesystem of the storage.
Sourcepub fn access(&self) -> Option<StorageAccess>
pub fn access(&self) -> Option<StorageAccess>
Retrieves the access capability over the storage.
Sourcepub fn total_space(&self) -> u64
pub fn total_space(&self) -> u64
Retrieves the total space in bytes of the storage.
Sourcepub fn free_space(&self) -> u64
pub fn free_space(&self) -> u64
Retrieves the free space in bytes of the storage.
Sourcepub fn format(&self) -> Result<()>
pub fn format(&self) -> Result<()>
Erases all data on the storage and formats it.
This function will permanently erase all data from the storage!
§Errors
Returns an error if the device doesn’t have a support for storage formatting or if the operation has failed.
Sourcepub fn iter(&self) -> ObjectIter<'_> ⓘ
pub fn iter(&self) -> ObjectIter<'_> ⓘ
Retrieves an iterator over the objects in the root of the storage.
Sourcepub fn iter_recursive(&self) -> ObjectRecursiveIter<'_> ⓘ
pub fn iter_recursive(&self) -> ObjectRecursiveIter<'_> ⓘ
Retrieves a recursive iterator over the objects of the storage.
Examples found in repository?
More examples
examples/copy-to-host.rs (line 7)
4fn main() -> libmtp::Result<()> {
5 let device = Device::from_serial("GVEV4I3E0WU1")?.expect("Device should exist");
6 let storage = device.find_storage(65537).expect("Storage should exist");
7 for object in storage.iter_recursive() {
8 if let Object::File(file) = object {
9 let path = format!("/tmp/libmtp-{}", file.name());
10 file.copy_to_host(path)?;
11 break;
12 }
13 }
14 Ok(())
15}Trait Implementations§
Source§impl<'a> IntoIterator for &'a Storage<'a>
impl<'a> IntoIterator for &'a Storage<'a>
impl<'a> Copy for Storage<'a>
Auto Trait Implementations§
impl<'a> Freeze for Storage<'a>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more