derive Clone and PartialEq for some API types

This is useful for react-lik GUI toolkits which need to do VDOM diffs.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2022-12-15 17:34:13 +01:00
parent 89052a009d
commit 915f6ab5d0
8 changed files with 29 additions and 18 deletions

View File

@ -270,7 +270,7 @@ pub const DATASTORE_TUNING_STRING_SCHEMA: Schema = StringSchema::new("Datastore
}, },
} }
)] )]
#[derive(Serialize, Deserialize, Updater)] #[derive(Serialize, Deserialize, Updater, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Datastore configuration properties. /// Datastore configuration properties.
pub struct DataStoreConfig { pub struct DataStoreConfig {
@ -354,7 +354,7 @@ impl DataStoreConfig {
} }
}, },
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Basic information about a datastore. /// Basic information about a datastore.
pub struct DataStoreListItem { pub struct DataStoreListItem {
@ -1141,7 +1141,7 @@ pub struct GroupListItem {
} }
#[api()] #[api()]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Basic information about a backup namespace. /// Basic information about a backup namespace.
pub struct NamespaceListItem { pub struct NamespaceListItem {
@ -1223,7 +1223,7 @@ pub struct TypeCounts {
}, },
}, },
)] )]
#[derive(Clone, Default, Serialize, Deserialize)] #[derive(Clone, Default, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Garbage collection status. /// Garbage collection status.
pub struct GarbageCollectionStatus { pub struct GarbageCollectionStatus {
@ -1295,7 +1295,7 @@ pub struct DataStoreStatus {
}, },
}, },
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Status of a Datastore /// Status of a Datastore
pub struct DataStoreStatusListItem { pub struct DataStoreStatusListItem {

View File

@ -121,7 +121,7 @@ fn strip_unit(v: &str) -> (&str, SizeUnit) {
} }
/// Byte size which can be displayed in a human friendly way /// Byte size which can be displayed in a human friendly way
#[derive(Debug, Copy, Clone, UpdaterType)] #[derive(Debug, Copy, Clone, UpdaterType, PartialEq)]
pub struct HumanByte { pub struct HumanByte {
/// The siginficant value, it does not includes any factor of the `unit` /// The siginficant value, it does not includes any factor of the `unit`
size: f64, size: f64,

View File

@ -87,7 +87,7 @@ pub const REMOVE_VANISHED_BACKUPS_SCHEMA: Schema = BooleanSchema::new(
}, },
} }
)] )]
#[derive(Serialize, Deserialize, Default)] #[derive(Serialize, Deserialize, Default, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Job Scheduling Status /// Job Scheduling Status
pub struct JobScheduleStatus { pub struct JobScheduleStatus {
@ -392,6 +392,17 @@ pub enum GroupFilter {
Regex(Regex), Regex(Regex),
} }
impl PartialEq for GroupFilter {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::BackupType(a), Self::BackupType(b)) => a == b,
(Self::Group(a), Self::Group(b)) => a == b,
(Self::Regex(a), Self::Regex(b)) => a.as_str() == b.as_str(),
_ => false,
}
}
}
impl std::str::FromStr for GroupFilter { impl std::str::FromStr for GroupFilter {
type Err = anyhow::Error; type Err = anyhow::Error;
@ -484,7 +495,7 @@ pub const GROUP_FILTER_LIST_SCHEMA: Schema =
}, },
} }
)] )]
#[derive(Serialize, Deserialize, Clone, Updater)] #[derive(Serialize, Deserialize, Clone, Updater, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Sync Job /// Sync Job
pub struct SyncJobConfig { pub struct SyncJobConfig {
@ -532,7 +543,7 @@ impl SyncJobConfig {
}, },
}, },
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Status of Sync Job /// Status of Sync Job
pub struct SyncJobStatus { pub struct SyncJobStatus {
@ -572,7 +583,7 @@ pub struct SyncJobStatus {
}, },
} }
)] )]
#[derive(Serialize, Deserialize, Default, Updater)] #[derive(Serialize, Deserialize, Default, Updater, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Common pruning options /// Common pruning options
pub struct KeepOptions { pub struct KeepOptions {

View File

@ -492,7 +492,7 @@ pub enum RRDTimeFrame {
} }
#[api] #[api]
#[derive(Deserialize, Serialize, PartialEq, Eq)] #[derive(Deserialize, Serialize, Copy, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
/// type of the realm /// type of the realm
pub enum RealmType { pub enum RealmType {
@ -518,7 +518,7 @@ pub enum RealmType {
}, },
}, },
)] )]
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Basic Information about a realm /// Basic Information about a realm
pub struct BasicRealmInfo { pub struct BasicRealmInfo {

View File

@ -46,7 +46,7 @@ pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
}, },
}, },
)] )]
#[derive(Serialize, Deserialize, Updater)] #[derive(Serialize, Deserialize, Updater, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Remote configuration properties. /// Remote configuration properties.
pub struct RemoteConfig { pub struct RemoteConfig {
@ -96,7 +96,7 @@ pub struct Remote {
}, },
}, },
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Remote properties. /// Remote properties.
pub struct RemoteWithoutPassword { pub struct RemoteWithoutPassword {

View File

@ -149,7 +149,7 @@ pub struct LabelUuidMap {
}, },
}, },
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Media content list entry /// Media content list entry
pub struct MediaContentEntry { pub struct MediaContentEntry {

View File

@ -48,7 +48,7 @@ pub const TRAFFIC_CONTROL_BURST_SCHEMA: Schema =
}, },
}, },
)] )]
#[derive(Serialize, Deserialize, Default, Clone, Updater)] #[derive(Serialize, Deserialize, Default, Clone, Updater, PartialEq)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
/// Rate Limit Configuration /// Rate Limit Configuration
pub struct RateLimitConfig { pub struct RateLimitConfig {

View File

@ -75,7 +75,7 @@ pub const EMAIL_SCHEMA: Schema = StringSchema::new("E-Mail Address.")
}, },
} }
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
/// User properties with added list of ApiTokens /// User properties with added list of ApiTokens
pub struct UserWithTokens { pub struct UserWithTokens {
pub userid: Userid, pub userid: Userid,
@ -114,7 +114,7 @@ pub struct UserWithTokens {
}, },
} }
)] )]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, PartialEq)]
/// ApiToken properties. /// ApiToken properties.
pub struct ApiToken { pub struct ApiToken {
pub tokenid: Authid, pub tokenid: Authid,