From 1e083c2df72a4c3eb8175293326a9cb72dd33098 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 8 Oct 2023 19:45:24 +0300 Subject: [PATCH] [Generic] Add missing derives to types --- CHANGELOG.md | 4 ++++ src/protocols/types.rs | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08bba07..bbc1009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ Protocols: - Minecraft Java: Add derives to `RequestSettings` and add `new_just_hostname` that creates new settings just by specifying the hostname, `protocol_version` defaults to -1. +Generics: +- Added derives to `GenericResponse` (serde), `GenericPlayer` (serde), `ProprietaryProtocol`, `CommonResponseJson`, +`CommonPlayerJson`, `TimeoutSettings`, `ExtraRequestSettings`. + ### Breaking... None, yaay! diff --git a/src/protocols/types.rs b/src/protocols/types.rs index a830e63..c00c00b 100644 --- a/src/protocols/types.rs +++ b/src/protocols/types.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; /// Enumeration of all custom protocols #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum ProprietaryProtocol { TheShip, FFOW, @@ -29,6 +29,7 @@ pub enum Protocol { } /// All response types +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, PartialEq)] pub enum GenericResponse<'a> { GameSpy(gamespy::VersionedResponse<'a>), @@ -44,6 +45,7 @@ pub enum GenericResponse<'a> { } /// All player types +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, PartialEq)] pub enum GenericPlayer<'a> { Valve(&'a valve::ServerPlayer), @@ -101,8 +103,8 @@ pub trait CommonResponse { fn players(&self) -> Option> { None } } -#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] -#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct CommonResponseJson<'a> { pub name: Option<&'a str>, pub description: Option<&'a str>, @@ -134,15 +136,16 @@ pub trait CommonPlayer { fn score(&self) -> Option { None } } -#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] -#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct CommonPlayerJson<'a> { pub name: &'a str, pub score: Option, } /// Timeout settings for socket operations -#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct TimeoutSettings { read: Option, write: Option, @@ -243,7 +246,8 @@ impl Default for TimeoutSettings { /// use gamedig::protocols::{valve, ExtraRequestSettings}; /// let valve_settings: valve::GatheringSettings = ExtraRequestSettings::default().set_check_app_id(false).into(); /// ``` -#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] pub struct ExtraRequestSettings { /// The server's hostname. ///