From a22c4c901ef6f784bf3caf6b68ef146510ef1172 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Tue, 22 Aug 2023 17:55:53 +0200 Subject: [PATCH] Implement Default for MessageSearchQuery --- src/types/schema/message.rs | 72 +++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/src/types/schema/message.rs b/src/types/schema/message.rs index 94a5884..e0ee804 100644 --- a/src/types/schema/message.rs +++ b/src/types/schema/message.rs @@ -39,32 +39,60 @@ impl std::fmt::Display for MessageSearchEndpoint { } } -#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq, PartialOrd, Ord)] /// Represents a Message Search Query JSON Body. /// The `channel_id` field is not applicable when using the `GET /channels/{channel.id}/messages/search` endpoint. /// /// # Reference: /// See pub struct MessageSearchQuery { - attachment_extension: Option>, - attachment_filename: Option>, - author_id: Option>, - author_type: Option>, - channel_id: Option>, - command_id: Option>, - content: Option, - embed_provider: Option>, - embed_type: Option>, - has: Option>, - include_nsfw: Option, - limit: Option, - link_hostname: Option>, - max_id: Option, - mention_everyone: Option, - mentions: Option>, - min_id: Option, - offset: Option, - pinned: Option, - sort_by: Option, - sort_order: Option, + pub attachment_extension: Option>, + pub attachment_filename: Option>, + pub author_id: Option>, + pub author_type: Option>, + pub channel_id: Option>, + pub command_id: Option>, + pub content: Option, + pub embed_provider: Option>, + pub embed_type: Option>, + pub has: Option>, + pub include_nsfw: Option, + pub limit: Option, + pub link_hostname: Option>, + pub max_id: Option, + pub mention_everyone: Option, + pub mentions: Option>, + pub min_id: Option, + pub offset: Option, + pub pinned: Option, + pub sort_by: Option, + pub sort_order: Option, +} + +impl std::default::Default for MessageSearchQuery { + fn default() -> Self { + Self { + attachment_extension: Default::default(), + attachment_filename: Default::default(), + author_id: Default::default(), + author_type: Default::default(), + channel_id: Default::default(), + command_id: Default::default(), + content: Default::default(), + embed_provider: Default::default(), + embed_type: Default::default(), + has: Default::default(), + include_nsfw: Some(false), + limit: Some(25), + link_hostname: Default::default(), + max_id: Default::default(), + mention_everyone: Default::default(), + mentions: Default::default(), + min_id: Default::default(), + offset: Some(0), + pinned: Default::default(), + sort_by: Default::default(), + sort_order: Default::default(), + } + } }