Struct File

Source
pub struct File<'a> { /* private fields */ }
Expand description

Abstraction of a file object, it implements Object, you may want to use this struct to create a tree representation of one storage.

Implementations§

Source§

impl File<'_>

Source

pub fn storage_id(&self) -> u32

Returns the id of the storage it belongs to.

Source

pub fn parent_id(&self) -> Parent

Returns the id of its parent.

Source

pub fn size(&self) -> u64

Returns the size of this file.

Source

pub fn name(&self) -> &str

Returns the name of this file.

Source

pub fn ftype(&self) -> Filetype

Returns the type of this file.

Source

pub fn modification_date(&self) -> DateTime<Utc>

Returns the latest modification date in UTC.

Source

pub fn rename(&mut self, new_name: &str) -> Result<()>

Rename this file in-place.

Trait Implementations§

Source§

impl Debug for File<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for File<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Object for &File<'_>

Source§

fn id(&self) -> u32

Must return the id of the object.
Source§

fn device(&self) -> &MtpDevice

Must return a valid reference of an MtpDevice, where this object resides in.
Source§

fn get_string(&self, property: Property) -> Result<String>

Retrieves a string from an object attribute.
Source§

fn set_string(&self, property: Property, string: &str) -> Result<()>

Sets an object attribute from a string.
Source§

fn get_u64(&self, property: Property) -> Result<u64>

Retrieves an u64 from an object attribute.
Source§

fn get_u32(&self, property: Property) -> Result<u32>

Retrieves an u32 from an object attribute, returns the value of default on failure.
Source§

fn set_u32(&self, property: Property, value: u32) -> Result<()>

Sets an object attribute from an u32.
Source§

fn get_u16(&self, property: Property) -> Result<u16>

Retrieves an u16 from an object attribute, returns the value of default on failure.
Source§

fn set_u16(&self, property: Property, value: u16) -> Result<()>

Sets an object attribute from an u16.
Source§

fn get_u8(&self, property: Property) -> Result<u8>

Retrieves an u8 from an object attribute, returns the value of default on failure.
Source§

fn set_u8(&self, property: Property, value: u8) -> Result<()>

Sets an object attribute from an u8.
Source§

fn delete(&self) -> Result<()>

Deletes a single file, track, playlist, folder or any other object off the MTP device. Note that deleting folders may no be remove its contents, in turn this is the expected behavior. Read more
Source§

fn move_to(&self, storage_id: u32, parent: Parent) -> Result<()>

Moves the object to the specified storage (by its id) and parent folder. Moving objects may or not be supported on the device. Read more
Source§

fn copy_to(&self, storage_id: u32, parent: Parent) -> Result<()>

Copies the object to the specified storage (by its id) and parent folder. Copying objects may or not be supported on the device. Read more
Source§

fn get_partial_object(&self, offset: u64, maxbytes: u32) -> Result<Vec<u8>>

Get partial data from an object, specifying an offset and the maximum bytes that should be read. Note that this may return fewer bytes than the maximum.
Source§

fn send_partial_object(&self, offset: u64, data: impl AsRef<[u8]>) -> Result<()>

Send partial data to an object, specifying an offset and the data you want to write into the object.
Source§

impl Object for File<'_>

Source§

fn id(&self) -> u32

Must return the id of the object.
Source§

fn device(&self) -> &MtpDevice

Must return a valid reference of an MtpDevice, where this object resides in.
Source§

fn get_string(&self, property: Property) -> Result<String>

Retrieves a string from an object attribute.
Source§

fn set_string(&self, property: Property, string: &str) -> Result<()>

Sets an object attribute from a string.
Source§

fn get_u64(&self, property: Property) -> Result<u64>

Retrieves an u64 from an object attribute.
Source§

fn get_u32(&self, property: Property) -> Result<u32>

Retrieves an u32 from an object attribute, returns the value of default on failure.
Source§

fn set_u32(&self, property: Property, value: u32) -> Result<()>

Sets an object attribute from an u32.
Source§

fn get_u16(&self, property: Property) -> Result<u16>

Retrieves an u16 from an object attribute, returns the value of default on failure.
Source§

fn set_u16(&self, property: Property, value: u16) -> Result<()>

Sets an object attribute from an u16.
Source§

fn get_u8(&self, property: Property) -> Result<u8>

Retrieves an u8 from an object attribute, returns the value of default on failure.
Source§

fn set_u8(&self, property: Property, value: u8) -> Result<()>

Sets an object attribute from an u8.
Source§

fn delete(&self) -> Result<()>

Deletes a single file, track, playlist, folder or any other object off the MTP device. Note that deleting folders may no be remove its contents, in turn this is the expected behavior. Read more
Source§

fn move_to(&self, storage_id: u32, parent: Parent) -> Result<()>

Moves the object to the specified storage (by its id) and parent folder. Moving objects may or not be supported on the device. Read more
Source§

fn copy_to(&self, storage_id: u32, parent: Parent) -> Result<()>

Copies the object to the specified storage (by its id) and parent folder. Copying objects may or not be supported on the device. Read more
Source§

fn get_partial_object(&self, offset: u64, maxbytes: u32) -> Result<Vec<u8>>

Get partial data from an object, specifying an offset and the maximum bytes that should be read. Note that this may return fewer bytes than the maximum.
Source§

fn send_partial_object(&self, offset: u64, data: impl AsRef<[u8]>) -> Result<()>

Send partial data to an object, specifying an offset and the data you want to write into the object.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsObjectId for T
where T: Object,

Source§

fn as_id(&self) -> u32

Treat the implementor as an object id.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.