Skip to main content

eve_log_parser/
models.rs

1use chrono::{DateTime, Utc};
2use log::debug;
3use serde::{Deserialize, Serialize};
4
5/// Log of damage
6#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
7pub struct DamageLog {
8    timestamp: DateTime<Utc>,
9    damage: isize,
10    other_player: String,
11    other_ship: String,
12    weapon: String,
13    destination: Destination,
14}
15
16impl DamageLog {
17    /// Builds a new DamageLog
18    pub fn new(
19        timestamp: DateTime<Utc>,
20        damage: isize,
21        other_player: String,
22        other_ship: String,
23        weapon: String,
24        destination: Destination,
25    ) -> Self {
26        debug!(
27            "Creating a new damagelog ({},{},{},{},{},{:?})",
28            timestamp, damage, other_player, other_ship, weapon, destination
29        );
30        DamageLog {
31            timestamp,
32            damage,
33            other_player,
34            other_ship,
35            weapon,
36            destination,
37        }
38    }
39}
40
41/// Log of logi reps
42#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
43pub struct LogiLog {
44    timestamp: DateTime<Utc>,
45    amount: isize,
46    other_player: String,
47    other_ship: String,
48    rep_type: String,
49    destination: Destination,
50}
51
52impl LogiLog {
53    /// Builds a new [LogiLog]
54    pub fn new(
55        timestamp: DateTime<Utc>,
56        amount: isize,
57        other_player: String,
58        other_ship: String,
59        rep_type: String,
60        destination: Destination,
61    ) -> Self {
62        debug!(
63            "Creating a new damagelog ({},{},{},{},{},{:?})",
64            timestamp, amount, other_player, other_ship, rep_type, destination
65        );
66        LogiLog {
67            timestamp,
68            amount,
69            other_player,
70            other_ship,
71            rep_type,
72            destination,
73        }
74    }
75}
76
77/// Represents if the log is created by the player or not
78#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
79pub enum Destination {
80    /// The log is received by the player
81    /// (being shot at, being repped, ...)
82    Receiving,
83    /// The log is initiated by the player
84    /// (shooting someone, repping someone, ...)
85    Dealing,
86}
87
88/// General struct embedding any kind of log
89#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
90pub enum Log {
91    Damage(DamageLog),
92    Logi(LogiLog),
93}