fix: switch to hashset

Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
Zomatree
2026-03-21 02:57:59 +00:00
parent ab159ccaa3
commit 3fd170a7de
2 changed files with 19 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
use iso8601_timestamp::Timestamp; use iso8601_timestamp::Timestamp;
use std::collections::HashSet;
auto_derived!( auto_derived!(
pub struct DataChannelMessagesSearch { pub struct DataChannelMessagesSearch {
@@ -13,24 +14,24 @@ auto_derived!(
pub struct DataChannelMessagesSearchFilters { pub struct DataChannelMessagesSearchFilters {
pub content: Option<String>, pub content: Option<String>,
pub author: Option<Vec<String>>, pub author: Option<HashSet<String>>,
pub mentions: Option<Vec<String>>, pub mentions: Option<HashSet<String>>,
pub role_mentions: Option<Vec<String>>, pub role_mentions: Option<HashSet<String>>,
pub before_date: Option<Timestamp>, pub before_date: Option<Timestamp>,
pub after_date: Option<Timestamp>, pub after_date: Option<Timestamp>,
pub author_type: Option<Vec<AuthorType>>, pub author_type: Option<HashSet<AuthorType>>,
pub pinned: Option<bool>, pub pinned: Option<bool>,
pub components: Option<Vec<MessageComponent>>, pub components: Option<HashSet<MessageComponent>>,
} }
#[derive(Copy)] #[derive(Copy, Hash)]
pub enum AuthorType { pub enum AuthorType {
User, User,
// Bot, // Bot,
Webhook, Webhook,
} }
#[derive(Copy)] #[derive(Copy, Hash)]
pub enum MessageComponent { pub enum MessageComponent {
Image, Image,
Video, Video,

View File

@@ -1,16 +1,18 @@
use std::collections::HashSet;
use iso8601_timestamp::Timestamp; use iso8601_timestamp::Timestamp;
use revolt_database::{File, Metadata};
use revolt_models::v0; use revolt_models::v0;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use revolt_database::{File, Metadata};
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Hash)]
pub enum AuthorType { pub enum AuthorType {
User, User,
// Bot, // Bot,
Webhook, Webhook,
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum MessageComponent { pub enum MessageComponent {
Image, Image,
Video, Video,
@@ -22,14 +24,14 @@ pub enum MessageComponent {
#[derive(Debug, Clone, Default, PartialEq)] #[derive(Debug, Clone, Default, PartialEq)]
pub struct SearchFilters { pub struct SearchFilters {
pub content: Option<String>, pub content: Option<String>,
pub author: Option<Vec<String>>, pub author: Option<HashSet<String>>,
pub mentions: Option<Vec<String>>, pub mentions: Option<HashSet<String>>,
pub role_mentions: Option<Vec<String>>, pub role_mentions: Option<HashSet<String>>,
pub before_date: Option<Timestamp>, pub before_date: Option<Timestamp>,
pub after_date: Option<Timestamp>, pub after_date: Option<Timestamp>,
pub author_type: Option<Vec<AuthorType>>, pub author_type: Option<HashSet<AuthorType>>,
pub pinned: Option<bool>, pub pinned: Option<bool>,
pub components: Option<Vec<MessageComponent>>, pub components: Option<HashSet<MessageComponent>>,
} }
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
@@ -51,7 +53,7 @@ pub struct SearchTerms {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MetadataFile { pub struct MetadataFile {
pub file: File, pub file: File,
pub metadata: Metadata pub metadata: Metadata,
} }
impl From<v0::AuthorType> for AuthorType { impl From<v0::AuthorType> for AuthorType {