pub trait Object {
Show 16 methods
// Required methods
fn id(&self) -> u32;
fn device(&self) -> &MtpDevice;
// Provided methods
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<()> { ... }
}
Expand description
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§
Provided Methods§
Sourcefn get_string(&self, property: Property) -> Result<String>
fn get_string(&self, property: Property) -> Result<String>
Retrieves a string from an object attribute.
Sourcefn set_string(&self, property: Property, string: &str) -> Result<()>
fn set_string(&self, property: Property, string: &str) -> Result<()>
Sets an object attribute from a string.
Sourcefn get_u64(&self, property: Property) -> Result<u64>
fn get_u64(&self, property: Property) -> Result<u64>
Retrieves an u64
from an object attribute.
Sourcefn get_u32(&self, property: Property) -> Result<u32>
fn get_u32(&self, property: Property) -> Result<u32>
Retrieves an u32
from an object attribute, returns the value of default
on failure.
Sourcefn set_u32(&self, property: Property, value: u32) -> Result<()>
fn set_u32(&self, property: Property, value: u32) -> Result<()>
Sets an object attribute from an u32
.
Sourcefn get_u16(&self, property: Property) -> Result<u16>
fn get_u16(&self, property: Property) -> Result<u16>
Retrieves an u16
from an object attribute, returns the value of default
on failure.
Sourcefn set_u16(&self, property: Property, value: u16) -> Result<()>
fn set_u16(&self, property: Property, value: u16) -> Result<()>
Sets an object attribute from an u16
.
Sourcefn get_u8(&self, property: Property) -> Result<u8>
fn get_u8(&self, property: Property) -> Result<u8>
Retrieves an u8
from an object attribute, returns the value of default
on failure.
Sourcefn set_u8(&self, property: Property, value: u8) -> Result<()>
fn set_u8(&self, property: Property, value: u8) -> Result<()>
Sets an object attribute from an u8
.
Sourcefn delete(&self) -> Result<()>
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.
Sourcefn move_to(&self, storage_id: u32, parent: Parent) -> Result<()>
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.
Sourcefn copy_to(&self, storage_id: u32, parent: Parent) -> Result<()>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.