From 4c9adbcbbcea6d47c009d464c6f9d30a15b7fb1e Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 28 Apr 2020 03:15:17 +0200 Subject: getters for Player/Character/Gadget --- src/lib.rs | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index e2e22fb..f438460 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,39 +39,66 @@ pub enum EvtcError { } /// Player-specific agent data. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] pub struct Player { /// The player's profession. + #[get_copy = "pub"] profession: u32, /// The player's elite specialization. + #[get_copy = "pub"] elite: u32, - /// The player's character name. character_name: String, - /// The player's account name. - /// - /// This includes the leading colon and the 4-digit denominator. account_name: String, /// The subgroup the player was in. + #[get_copy = "pub"] subgroup: u8, } +impl Player { + /// The player's character name. + pub fn character_name(&self) -> &str { + &self.character_name + } + + /// The player's account name. + /// + /// This includes the leading colon and the 4-digit denominator. + pub fn account_name(&self) -> &str { + &self.account_name + } +} + /// Gadget-specific agent data. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] pub struct Gadget { + #[get_copy = "pub"] id: u16, name: String, } -#[derive(Debug, Clone, PartialEq, Eq)] +impl Gadget { + pub fn name(&self) -> &str { + &self.name + } +} + +#[derive(Debug, Clone, PartialEq, Eq, CopyGetters)] pub struct Character { + #[get_copy = "pub"] id: u16, name: String, } +impl Character { + pub fn name(&self) -> &str { + &self.name + } +} + /// The type of an agent. #[derive(Debug, Clone, PartialEq, Eq)] pub enum AgentKind { -- cgit v1.2.3