aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2024-08-26 18:49:17 +0200
committerDaniel Schadt <kingdread@gmx.de>2024-08-26 18:49:17 +0200
commita8e05c660059a19994b46a2949d1c79ca4b4d579 (patch)
tree4c3b5216dcd316c6d084c68637270615e18ea443
parent01e68e3e7b0b5735f8a85a7b547fe14d50e9be7e (diff)
downloadevtclib-a8e05c660059a19994b46a2949d1c79ca4b4d579.tar.gz
evtclib-a8e05c660059a19994b46a2949d1c79ca4b4d579.tar.bz2
evtclib-a8e05c660059a19994b46a2949d1c79ca4b4d579.zip
fix clippy suggestions
-rw-r--r--src/agent.rs2
-rw-r--r--src/event.rs6
-rw-r--r--src/lib.rs2
-rw-r--r--src/raw/types.rs60
4 files changed, 22 insertions, 48 deletions
diff --git a/src/agent.rs b/src/agent.rs
index 4076df2..dae9f56 100644
--- a/src/agent.rs
+++ b/src/agent.rs
@@ -618,7 +618,7 @@ impl TryFrom<&raw::Agent> for Agent {
condition: raw_agent.condition,
instance_id: 0,
first_aware: 0,
- last_aware: u64::max_value(),
+ last_aware: u64::MAX,
master_agent: None,
phantom_data: PhantomData,
})
diff --git a/src/event.rs b/src/event.rs
index b6caa5d..609992b 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -4,6 +4,7 @@
use super::raw;
use std::convert::TryFrom;
+use std::fmt::Write;
use std::io;
use byteorder::{BigEndian, WriteBytesExt, LE};
@@ -549,7 +550,10 @@ fn get_api_guild_string(bytes: &[u8; 16]) -> Option<String> {
];
let result = PACKS
.iter()
- .map(|p| p.iter().map(|i| format!("{:02X}", bytes[*i])).collect())
+ .map(|p| p.iter().fold(String::new(), |mut output, i| {
+ let _ = write!(output, "{:02X}", bytes[*i]);
+ output
+ }))
.collect::<Vec<String>>()
.join("-");
Some(result)
diff --git a/src/lib.rs b/src/lib.rs
index 3677871..488cd45 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -82,7 +82,7 @@
//! reasons:
//!
//! * The only sensible source for logs is the arcdps addon itself, most applications only consume
-//! them.
+//! them.
//! * The library was needed for reading support, and writing support has never been a priority.
//!
//! While there are legitimate use cases for writing/modification support, they are currently not
diff --git a/src/raw/types.rs b/src/raw/types.rs
index ce22f5f..1bc3d08 100644
--- a/src/raw/types.rs
+++ b/src/raw/types.rs
@@ -7,7 +7,7 @@ use std::hash::Hash;
/// The "friend or foe" enum.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum IFF {
/// Green vs green, red vs red.
Friend,
@@ -16,18 +16,13 @@ pub enum IFF {
/// Something very wrong happened.
Unknown,
/// Field is not used in this kind of event.
+ #[default]
None,
}
-impl Default for IFF {
- fn default() -> Self {
- IFF::None
- }
-}
-
/// Combat result (physical)
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum CbtResult {
/// Good physical hit
Normal,
@@ -52,20 +47,16 @@ pub enum CbtResult {
/// Hit was breakbar damage.
Breakbar,
/// Field is not used in this kind of event.
+ #[default]
None,
}
-impl Default for CbtResult {
- fn default() -> Self {
- CbtResult::None
- }
-}
-
/// Combat activation
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum CbtActivation {
/// Field is not used in this kind of event.
+ #[default]
None,
/// Activation without quickness
Normal,
@@ -79,20 +70,15 @@ pub enum CbtActivation {
Reset,
}
-impl Default for CbtActivation {
- fn default() -> Self {
- CbtActivation::None
- }
-}
-
/// Combat state change
///
/// 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)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum CbtStateChange {
/// Field is not used in this kind of event.
+ #[default]
None,
/// `src_agent` entered combat.
///
@@ -213,17 +199,12 @@ pub enum CbtStateChange {
BarrierUpdate,
}
-impl Default for CbtStateChange {
- fn default() -> Self {
- CbtStateChange::None
- }
-}
-
/// Combat buff remove type
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum CbtBuffRemove {
/// Field is not used in this kind of event.
+ #[default]
None,
/// All stacks removed.
All,
@@ -237,12 +218,6 @@ pub enum CbtBuffRemove {
Manual,
}
-impl Default for CbtBuffRemove {
- fn default() -> Self {
- CbtBuffRemove::None
- }
-}
-
/// Custom skill ids
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
@@ -257,9 +232,10 @@ pub enum CbtCustomSkill {
/// Language
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)]
+#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)]
pub enum Language {
/// English.
+ #[default]
Eng = 0,
/// French.
Fre = 2,
@@ -269,12 +245,6 @@ pub enum Language {
Spa = 4,
}
-impl Default for Language {
- fn default() -> Self {
- Language::Eng
- }
-}
-
/// Buff formula attributes.
///
/// Variants prefixed with `Custom` are not native to the game client but rather variants added by
@@ -402,7 +372,7 @@ impl Agent {
/// Gadgets are entities spawned by some skills, like the "Binding Roots"
/// spawned by Entangle.
pub fn is_gadget(&self) -> bool {
- self.is_elite == std::u32::MAX && (self.prof & 0xffff_0000) == 0xffff_0000
+ self.is_elite == u32::MAX && (self.prof & 0xffff_0000) == 0xffff_0000
}
/// Checks whether this agent is a character.
@@ -410,12 +380,12 @@ impl Agent {
/// Characters are entities like clones, pets, minions, spirits, but also
/// minis.
pub fn is_character(&self) -> bool {
- self.is_elite == std::u32::MAX && (self.prof & 0xffff_0000) != 0xffff_0000
+ self.is_elite == u32::MAX && (self.prof & 0xffff_0000) != 0xffff_0000
}
/// Checks whether this agent is a player.
pub fn is_player(&self) -> bool {
- self.is_elite != std::u32::MAX
+ self.is_elite != u32::MAX
}
}