diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event.rs | 4 | ||||
-rw-r--r-- | src/gamedata.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 6 | ||||
-rw-r--r-- | src/raw/types.rs | 10 |
4 files changed, 24 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs index f9ee8e5..f90ed3a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -26,6 +26,7 @@ pub enum FromRawEventError { /// A rusty enum for all possible combat events. /// /// This makes dealing with [`CbtEvent`][raw::CbtEvent] a bit saner (and safer). +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq)] pub enum EventKind { // State change events @@ -213,6 +214,7 @@ pub enum EventKind { /// /// Note that if you plan on re-using the raw event afterwards, you should use the implementation /// that works on a reference instead: `Event::try_from(&raw_event)`. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, CopyGetters, Getters)] pub struct Event { /// The time when the event happened. @@ -524,6 +526,7 @@ fn get_error_bytes(raw_event: &raw::CbtEvent) -> [u8; 32] { } /// The different weapon-sets in game. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum WeaponSet { /// First water weapon set. @@ -558,6 +561,7 @@ impl WeaponSet { /// The different types to activate a skill. /// /// The parameter is the animation time in milliseconds. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Activation { /// The skill was activated with quickness. diff --git a/src/gamedata.rs b/src/gamedata.rs index 8d0bb7f..64b6731 100644 --- a/src/gamedata.rs +++ b/src/gamedata.rs @@ -15,6 +15,7 @@ use thiserror::Error; /// /// This enum is non-exhaustive to ensure that future encounters can be added without /// inducing a breaking change. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive)] #[non_exhaustive] #[repr(u16)] @@ -193,6 +194,7 @@ impl Display for Encounter { /// /// This enum is non-exhaustive to ensure that future bosses can be added without /// inducing a breaking change. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, FromPrimitive)] #[non_exhaustive] #[repr(u16)] @@ -516,6 +518,7 @@ pub struct ParseProfessionError(String); /// /// This only contains the 9 base professions. For elite specializations, see /// [`EliteSpec`][EliteSpec]. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, FromPrimitive)] pub enum Profession { Guardian = 1, @@ -576,6 +579,7 @@ pub struct ParseEliteSpecError(String); /// Note that the numeric value of the enum variants correspond to the specialization ID in the API /// as well. See [the official wiki](https://wiki.guildwars2.com/wiki/API:2/specializations) for /// more information regarding the API usage. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, FromPrimitive)] pub enum EliteSpec { // Heart of Thorns elites: @@ -145,6 +145,7 @@ pub enum EvtcError { /// Note that a `Player` is only the player character itself. Any additional entities that are /// spawned by the player (clones, illusions, banners, ...) are either a [`Character`][Character] /// or a [`Gadget`][Gadget]. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Player { /// The player's profession. @@ -186,6 +187,7 @@ impl Player { /// Examples of this include the [banners](https://wiki.guildwars2.com/wiki/Banner) spawned by /// Warriors, but also skill effects like the roots created by /// [Entangle](https://wiki.guildwars2.com/wiki/Entangle) or the other objects in the arena. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Gadget { /// The id of the gadget. @@ -208,6 +210,7 @@ impl Gadget { /// /// Characters are NPCs such as the bosses themselves, additional mobs that they spawn, but also /// friendly characters like Mesmer's clones and illusions, Necromancer minions, and so on. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Hash, PartialEq, Eq, CopyGetters)] pub struct Character { /// The id of the character. @@ -242,6 +245,7 @@ impl Character { /// // Convert it /// let agent: AgentKind = raw_agent.try_into().unwrap(); /// ``` +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum AgentKind { /// The agent is a player. @@ -440,6 +444,7 @@ impl TryFrom<&raw::Agent> for AgentKind { /// `Kind`. An escape hatch is the method [`.erase()`][Agent::erase], which erases the kind /// information and produces the default `Agent<()>`. Functions/methods that only take `Agent<()>` /// can therefore be used by any other agent as well. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone, Hash, PartialEq, Eq, Getters, CopyGetters)] // For the reasoning of #[repr(C)] see Agent::transmute. #[repr(C)] @@ -700,6 +705,7 @@ impl Agent<Character> { } /// A fully processed log file. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone)] pub struct Log { agents: Vec<Agent>, diff --git a/src/raw/types.rs b/src/raw/types.rs index fe4a907..0f840bd 100644 --- a/src/raw/types.rs +++ b/src/raw/types.rs @@ -7,6 +7,7 @@ use std::{self, fmt}; use std::hash::{Hash, Hasher}; /// The "friend or foe" enum. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum IFF { /// Green vs green, red vs red. @@ -26,6 +27,7 @@ impl Default for IFF { } /// Combat result (physical) +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtResult { /// Good physical hit @@ -59,6 +61,7 @@ impl Default for CbtResult { } /// Combat activation +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtActivation { /// Field is not used in this kind of event. @@ -85,6 +88,7 @@ impl Default for CbtActivation { /// /// The referenced fields are of the [`CbtEvent`](struct.CbtEvent.html) /// struct. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtStateChange { /// Field is not used in this kind of event. @@ -212,6 +216,7 @@ impl Default for CbtStateChange { } /// Combat buff remove type +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtBuffRemove { /// Field is not used in this kind of event. @@ -235,6 +240,7 @@ impl Default for CbtBuffRemove { } /// Custom skill ids +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtCustomSkill { /// Not custom but important and unnamed. @@ -246,6 +252,7 @@ pub enum CbtCustomSkill { } /// Language +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum Language { /// English. @@ -270,6 +277,7 @@ impl Default for Language { /// arcdps. /// /// The suffix `Inc` indicates an increase, whereas the suffix `Rec` stands for received. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum Attribute { None, @@ -294,6 +302,7 @@ pub enum Attribute { } /// Categories for [`BuffInfo`][CbtStateChange::BuffInfo] events. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] pub enum BuffCategory { Boon = 0, @@ -314,6 +323,7 @@ pub enum BuffCategory { /// to check the header.revision tag. /// /// For conflicting data types, the bigger one is chosen (e.g. u32 over u16). +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash, Default)] pub struct CbtEvent { /// System time since Windows was started, in milliseconds. |