mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
[Generic] Add missing derives to types
This commit is contained in:
parent
7164ab5f64
commit
1e083c2df7
2 changed files with 15 additions and 7 deletions
|
|
@ -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!
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Vec<&dyn CommonPlayer>> { 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<i32> { 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<i32>,
|
||||
}
|
||||
|
||||
/// 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<Duration>,
|
||||
write: Option<Duration>,
|
||||
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue