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

1//! Fired whenever the player approaches a body.
2
3use serde::{Deserialize, Serialize};
4
5/// Fired whenever the player approaches a body. This is usually when the game also performs a scan
6/// which fires a [ScanEvent](crate::logs::scan_event::ScanEvent).
7#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
8#[serde(rename_all = "PascalCase")]
9pub struct ApproachBodyEvent {
10    /// The star system the approached body is part of.
11    pub star_system: String,
12
13    /// The name of the body which the player is approaching.
14    pub body: String,
15}
16
17#[cfg(test)]
18mod tests {
19    use serde_json::json;
20
21    use crate::logs::content::log_event_content::approach_body_event::ApproachBodyEvent;
22
23    #[test]
24    fn approach_body_is_parsed_correctly() {
25        let value: ApproachBodyEvent = serde_json::from_value(json!({
26            "StarSystem": "Eranin",
27            "Body": "Eranin 2"
28        }))
29        .unwrap();
30
31        let expected = ApproachBodyEvent {
32            star_system: "Eranin".to_string(),
33            body: "Eranin 2".to_string(),
34        };
35
36        assert_eq!(value, expected);
37    }
38}