[][src]Trait libmtp_rs::object::Object

pub trait Object {
    fn id(&self) -> u32;
fn device(&self) -> &MtpDevice; fn get_string(&self, property: Property) -> Result<String> { ... }
fn set_string(&self, property: Property, string: &str) -> Result<()> { ... }
fn get_u64(&self, property: Property) -> Result<u64> { ... }
fn get_u32(&self, property: Property) -> Result<u32> { ... }
fn set_u32(&self, property: Property, value: u32) -> Result<()> { ... }
fn get_u16(&self, property: Property) -> Result<u16> { ... }
fn set_u16(&self, property: Property, value: u16) -> Result<()> { ... }
fn get_u8(&self, property: Property) -> Result<u8> { ... }
fn set_u8(&self, property: Property, value: u8) -> Result<()> { ... }
fn delete(&self) -> Result<()> { ... }
fn move_to(&self, storage_id: u32, parent: Parent) -> Result<()> { ... }
fn copy_to(&self, storage_id: u32, parent: Parent) -> Result<()> { ... }
fn get_partial_object(&self, offset: u64, maxbytes: u32) -> Result<Vec<u8>> { ... }
fn send_partial_object(
        &self,
        offset: u64,
        data: impl AsRef<[u8]>
    ) -> Result<()> { ... } }

Common behavior of many higher abstractions is grouped in this trait, basically everything on MTP is an object with some attributes, even though this API is exposed, it's not recommended to use it to modify or get attributes that can be managed with other specefic APIs (like files, folders, tracks, etc).

Required methods

fn id(&self) -> u32

Must return the id of the object.

fn device(&self) -> &MtpDevice

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

Loading content...

Provided methods

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

Retrieves a string from an object attribute.

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

Sets an object attribute from a string.

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

Retrieves an u64 from an object attribute.

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

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

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

Sets an object attribute from an u32.

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

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

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

Sets an object attribute from an u16.

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

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

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

Sets an object attribute from an u8.

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.

If you want to delete a folder first recursively delete all files and folders contained in this folder, then the folder itself. Finally, if the operation is sucessful you should discard the object given that now it holds an invalid id.

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.

Note that moving an object may take a significant amount of time, particularly if being moved between storages, MTP doesn't provide any kind of progress mechanism, so the operation will simply block for the duration.

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.

Note that copying an object may take a significant amount of time, particularly if being copied between storages, MTP doesn't provide any kind of progress mechanism, so the operation will simply block for the duration.

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.

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.

Loading content...

Implementors

impl<'_> Object for DummyObject<'_>[src]

impl<'_> Object for File<'_>[src]

impl<'_> Object for Folder<'_>[src]

impl<'_, '_> Object for &'_ File<'_>[src]

impl<'_, '_> Object for &'_ Folder<'_>[src]

Loading content...