mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +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
|
- 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.
|
the hostname, `protocol_version` defaults to -1.
|
||||||
|
|
||||||
|
Generics:
|
||||||
|
- Added derives to `GenericResponse` (serde), `GenericPlayer` (serde), `ProprietaryProtocol`, `CommonResponseJson`,
|
||||||
|
`CommonPlayerJson`, `TimeoutSettings`, `ExtraRequestSettings`.
|
||||||
|
|
||||||
### Breaking...
|
### Breaking...
|
||||||
None, yaay!
|
None, yaay!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Enumeration of all custom protocols
|
/// Enumeration of all custom protocols
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub enum ProprietaryProtocol {
|
pub enum ProprietaryProtocol {
|
||||||
TheShip,
|
TheShip,
|
||||||
FFOW,
|
FFOW,
|
||||||
|
|
@ -29,6 +29,7 @@ pub enum Protocol {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All response types
|
/// All response types
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum GenericResponse<'a> {
|
pub enum GenericResponse<'a> {
|
||||||
GameSpy(gamespy::VersionedResponse<'a>),
|
GameSpy(gamespy::VersionedResponse<'a>),
|
||||||
|
|
@ -44,6 +45,7 @@ pub enum GenericResponse<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All player types
|
/// All player types
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum GenericPlayer<'a> {
|
pub enum GenericPlayer<'a> {
|
||||||
Valve(&'a valve::ServerPlayer),
|
Valve(&'a valve::ServerPlayer),
|
||||||
|
|
@ -101,8 +103,8 @@ pub trait CommonResponse {
|
||||||
fn players(&self) -> Option<Vec<&dyn CommonPlayer>> { None }
|
fn players(&self) -> Option<Vec<&dyn CommonPlayer>> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct CommonResponseJson<'a> {
|
pub struct CommonResponseJson<'a> {
|
||||||
pub name: Option<&'a str>,
|
pub name: Option<&'a str>,
|
||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
|
|
@ -134,15 +136,16 @@ pub trait CommonPlayer {
|
||||||
fn score(&self) -> Option<i32> { None }
|
fn score(&self) -> Option<i32> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct CommonPlayerJson<'a> {
|
pub struct CommonPlayerJson<'a> {
|
||||||
pub name: &'a str,
|
pub name: &'a str,
|
||||||
pub score: Option<i32>,
|
pub score: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Timeout settings for socket operations
|
/// 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 {
|
pub struct TimeoutSettings {
|
||||||
read: Option<Duration>,
|
read: Option<Duration>,
|
||||||
write: Option<Duration>,
|
write: Option<Duration>,
|
||||||
|
|
@ -243,7 +246,8 @@ impl Default for TimeoutSettings {
|
||||||
/// use gamedig::protocols::{valve, ExtraRequestSettings};
|
/// use gamedig::protocols::{valve, ExtraRequestSettings};
|
||||||
/// let valve_settings: valve::GatheringSettings = ExtraRequestSettings::default().set_check_app_id(false).into();
|
/// 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 {
|
pub struct ExtraRequestSettings {
|
||||||
/// The server's hostname.
|
/// The server's hostname.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue