f1_game_packet_parser/packets/
time_trial.rs1use super::{u8_to_bool, u8_to_usize};
2use crate::constants::{GearboxAssist, TractionControl, MAX_NUM_CARS};
3
4use binrw::BinRead;
5use serde::{Deserialize, Serialize};
6
7#[allow(clippy::struct_excessive_bools)]
8#[non_exhaustive]
9#[derive(
10 BinRead, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize,
11)]
12#[br(little, import(_packet_format: u16))]
13pub struct TimeTrialDataSet {
14 #[br(
16 map(u8_to_usize),
17 assert(
18 vehicle_index < MAX_NUM_CARS,
19 "Time trial data set has an invalid vehicle index: {}",
20 vehicle_index
21 )
22 )]
23 pub vehicle_index: usize,
24 pub team_id: u8,
27 pub lap_time_ms: u32,
29 pub sector1_time_ms: u32,
31 pub sector2_time_ms: u32,
33 pub sector3_time_ms: u32,
35 pub traction_control: TractionControl,
37 pub gearbox_assist: GearboxAssist,
39 #[br(try_map(u8_to_bool))]
41 pub anti_lock_brakes: bool,
42 #[br(try_map(u8_to_bool))]
44 pub equal_car_performance: bool,
45 #[br(try_map(u8_to_bool))]
47 pub custom_setup: bool,
48 #[br(try_map(u8_to_bool))]
50 pub valid: bool,
51}