f1_game_packet_parser/packets/
participants.rs

1use super::{read_name, u8_to_bool};
2use crate::constants::{Nationality, Platform, YourTelemetry};
3
4use binrw::BinRead;
5use serde::{Deserialize, Serialize};
6
7#[non_exhaustive]
8#[derive(
9    BinRead, Eq, PartialEq, Ord, PartialOrd, Clone, Debug, Serialize, Deserialize,
10)]
11#[br(little, import(packet_format: u16))]
12pub struct ParticipantsData {
13    /// Whether the vehicle is controlled by AI.
14    #[br(try_map(u8_to_bool))]
15    pub ai_controlled: bool,
16    /// Driver's ID.
17    /// See [`driver_id`](mod@crate::constants::driver_id)
18    /// for possible values.
19    pub driver_id: u8,
20    /// Unique ID for network players.
21    pub network_id: u8,
22    /// Team's ID.
23    /// See [`team_id`](mod@crate::constants::team_id) for possible values.
24    pub team_id: u8,
25    /// Whether my team is being used.
26    #[br(try_map(u8_to_bool))]
27    pub my_team: bool,
28    /// Race number of the car.
29    pub race_number: u8,
30    /// Driver's nationality.
31    pub nationality: Nationality,
32    /// Driver's name.
33    #[br(try_map(read_name))]
34    pub name: String,
35    /// Player's UDP visibility setting.
36    pub your_telemetry: Option<YourTelemetry>,
37    /// Whether this player's "show online names" setting is on.
38    /// Available from the 2023 format onwards.
39    #[br(if(packet_format >= 2023), try_map(u8_to_bool))]
40    pub show_online_names: bool,
41    /// F1 World tech level.
42    /// Available from the 2024 format onwards.
43    #[br(if(packet_format >= 2024))]
44    pub tech_level: u16,
45    /// Player's platform.
46    /// Available from the 2023 format onwards.
47    #[br(if(packet_format >= 2023))]
48    pub platform: Option<Platform>,
49}