pub struct File<'a> { /* private fields */ }Expand description
A file on the storage.
Implementations§
Source§impl<'a> File<'a>
impl<'a> File<'a>
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
examples/copy-to-host.rs (line 9)
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}Sourcepub fn move_to(&self, parent: Folder<'_>) -> Result<()>
pub fn move_to(&self, parent: Folder<'_>) -> Result<()>
Moves the file to the other folder.
§Errors
Returns an error if an object with the same name already exists in the other folder or if the operation has failed.
Sourcepub fn copy_to(&self, parent: Folder<'_>) -> Result<()>
pub fn copy_to(&self, parent: Folder<'_>) -> Result<()>
Copies the file to the other folder.
§Errors
Returns an error if an object with the same name already exists in the other folder or if the operation has failed.
Sourcepub fn copy_to_host<P>(&self, path: P) -> Result<()>
pub fn copy_to_host<P>(&self, path: P) -> Result<()>
Examples found in repository?
examples/copy-to-host.rs (line 10)
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§
Auto Trait Implementations§
impl<'a> Freeze for File<'a>
impl<'a> RefUnwindSafe for File<'a>
impl<'a> !Send for File<'a>
impl<'a> !Sync for File<'a>
impl<'a> Unpin for File<'a>
impl<'a> UnwindSafe for File<'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