From 7318ec6ef675a53b4ecc1c5e74ca99b1d7c48d37 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Tue, 1 Aug 2023 15:54:56 +0100 Subject: [PATCH] chore(core/models): add cfg_attr where necessary --- crates/core/models/src/v0/bots.rs | 6 +++--- crates/core/models/src/v0/files.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/core/models/src/v0/bots.rs b/crates/core/models/src/v0/bots.rs index 354ca555..8e71e715 100644 --- a/crates/core/models/src/v0/bots.rs +++ b/crates/core/models/src/v0/bots.rs @@ -65,16 +65,16 @@ auto_derived!( /// Public Bot pub struct PublicBot { /// Bot Id - #[serde(rename = "_id")] + #[cfg_attr(feature = "serde", serde(rename = "_id"))] pub id: String, /// Bot Username pub username: String, /// Profile Avatar - #[serde(skip_serializing_if = "String::is_empty")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "String::is_empty"))] pub avatar: String, /// Profile Description - #[serde(skip_serializing_if = "String::is_empty")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "String::is_empty"))] pub description: String, } diff --git a/crates/core/models/src/v0/files.rs b/crates/core/models/src/v0/files.rs index df30b216..b996483c 100644 --- a/crates/core/models/src/v0/files.rs +++ b/crates/core/models/src/v0/files.rs @@ -2,7 +2,7 @@ auto_derived!( /// File pub struct File { /// Unique Id - #[serde(rename = "_id")] + #[cfg_attr(feature = "serde", serde(rename = "_id"))] pub id: String, /// Tag / bucket this file was uploaded to pub tag: String, @@ -16,29 +16,29 @@ auto_derived!( pub size: isize, /// Whether this file was deleted - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub deleted: Option, /// Whether this file was reported - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub reported: Option, // TODO: migrate this mess to having: // - author_id // - parent: Parent { Message(id), User(id), etc } - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub message_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub user_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub server_id: Option, /// Id of the object this file is associated with - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] pub object_id: Option, } /// Metadata associated with a file - #[serde(tag = "type")] + #[cfg_attr(feature = "serde", serde(tag = "type"))] #[derive(Default)] pub enum Metadata { /// File is just a generic uncategorised file