ed_journals/modules/logs/content/log_event_content/
approach_body_event.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Fired whenever the player approaches a body.

use serde::{Deserialize, Serialize};

/// Fired whenever the player approaches a body. This is usually when the game also performs a scan
/// which fires a [ScanEvent](crate::logs::scan_event::ScanEvent).
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ApproachBodyEvent {
    /// The star system the approached body is part of.
    pub star_system: String,

    /// The name of the body which the player is approaching.
    pub body: String,
}

#[cfg(test)]
mod tests {
    use serde_json::json;

    use crate::logs::content::log_event_content::approach_body_event::ApproachBodyEvent;

    #[test]
    fn approach_body_is_parsed_correctly() {
        let value: ApproachBodyEvent = serde_json::from_value(json!({
            "StarSystem": "Eranin",
            "Body": "Eranin 2"
        }))
        .unwrap();

        let expected = ApproachBodyEvent {
            star_system: "Eranin".to_string(),
            body: "Eranin 2".to_string(),
        };

        assert_eq!(value, expected);
    }
}