diff --git a/src/device.rs b/src/device.rs index c90038a..e335822 100644 --- a/src/device.rs +++ b/src/device.rs @@ -22,7 +22,7 @@ use crate::values::AllowedValues; use crate::Result; /// Sorting logic to apply after the update of storages. -#[derive(Debug, Clone, Copy, ToPrimitive)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, ToPrimitive)] pub enum StorageSort { /// Do not sort the storages NotSorted = 0, @@ -39,7 +39,7 @@ pub enum StorageSort { /// whether there isn't enough information about the storage (`OnlyIds` where retrieved). /// Note that `StoragePool` and `Storage` instances have knowledge about the result /// of `update_storage`. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum UpdateResult { /// No errors, everything went fine. Success, @@ -58,7 +58,7 @@ pub enum UpdateResult { /// BatteryLevel::OnExternalPower => println!("Using external power, connected to AC"), /// } /// ``` -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, PartialEq, Eq, Clone)] pub enum BatteryLevel { /// The device is currently on battery. OnBattery(u8), diff --git a/src/device/capabilities.rs b/src/device/capabilities.rs index 0ac6902..defed46 100644 --- a/src/device/capabilities.rs +++ b/src/device/capabilities.rs @@ -5,7 +5,7 @@ use num_derive::{FromPrimitive, ToPrimitive}; /// Supported `libmtp` device capabilities, you can test if an MTP device supports /// one of those with [`MtpDevice::check_capability`](../struct.MtpDevice.html#method.check_capability) -#[derive(Debug, Clone, FromPrimitive, ToPrimitive)] +#[derive(Debug, Clone, PartialEq, Eq, FromPrimitive, ToPrimitive)] pub enum DeviceCapability { /// This capability tells whether you can get partial objects. GetPartialObject = 0, diff --git a/src/error.rs b/src/error.rs index f494252..1e1d19f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,7 +6,7 @@ use thiserror::Error as ErrorTrait; /// Enumeration of possible `libmtp` errors, check /// [`Error::MtpError`](enum.Error.html#variant.MtpError) for more information. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum MtpErrorKind { General, PtpLayer, diff --git a/src/object/filetypes.rs b/src/object/filetypes.rs index 70fcd83..0bdf12c 100644 --- a/src/object/filetypes.rs +++ b/src/object/filetypes.rs @@ -9,7 +9,7 @@ use std::fmt::{self, Display}; /// Enumeration that holds the supported filetypes, this enum implements `Display` /// with the description of the file type. -#[derive(Debug, Clone, FromPrimitive, ToPrimitive)] +#[derive(Debug, Clone, PartialEq, Eq, FromPrimitive, ToPrimitive)] pub enum Filetype { Folder = 0, Wav, diff --git a/src/object/properties.rs b/src/object/properties.rs index 9029119..cb87f7a 100644 --- a/src/object/properties.rs +++ b/src/object/properties.rs @@ -10,7 +10,7 @@ use std::fmt::{self, Display}; /// Enumeration that holds the supported properties, this enum implements `Display` with the /// description of the property. -#[derive(Debug, Clone, Copy, FromPrimitive, ToPrimitive)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)] pub enum Property { StorageId = 0, ObjectFormat, diff --git a/src/storage.rs b/src/storage.rs index ff3aa51..788edcc 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -49,7 +49,7 @@ fn files_and_folders(mtpdev: &MtpDevice, storage_id: u32, parent: Parent) -> Vec /// Represents the parent folder of an object, the top-most parent is called the "root" as in /// *nix like systems. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Parent { Root, Folder(u32), @@ -71,7 +71,7 @@ impl Parent { } } -#[derive(Debug, Copy, Clone, FromPrimitive)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, FromPrimitive)] pub enum StorageType { Undefined = 0, FixedRom, @@ -80,7 +80,7 @@ pub enum StorageType { RemovableRam, } -#[derive(Debug, Copy, Clone, FromPrimitive)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, FromPrimitive)] pub enum FilesystemType { Undefined = 0, GenericFlat, @@ -88,7 +88,7 @@ pub enum FilesystemType { DesignCameraFilesystem, } -#[derive(Debug, Copy, Clone, FromPrimitive)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, FromPrimitive)] pub enum AccessCapability { ReadWrite = 0, ReadOnly, diff --git a/src/storage/files.rs b/src/storage/files.rs index 31cff18..496897a 100644 --- a/src/storage/files.rs +++ b/src/storage/files.rs @@ -108,7 +108,7 @@ impl File<'_> { /// Returns the latest modification date in UTC. pub fn modification_date(&self) -> DateTime { let epoch = unsafe { (*self.inner).modificationdate }; - Utc.timestamp(epoch, 0) + Utc.timestamp_opt(epoch, 0).unwrap() } /// Rename this file in-place.