refactor: use from_bits_retain instead of truncate when reading bitmap fields

This commit is contained in:
Maciej Pędzich 2025-02-23 18:22:37 +01:00
parent f011e68702
commit 1bdf45a1ee
Signed by: maciejpedzich
GPG Key ID: CE4A303D84882F0D
3 changed files with 6 additions and 6 deletions

View File

@ -70,7 +70,7 @@ pub struct CarTelemetryData {
)]
pub rev_lights_percent: u8,
/// Bitmap of active rev lights.
#[br(map(RevLights::from_bits_truncate))]
#[br(map(RevLights::from_bits_retain))]
pub rev_lights_bit_value: RevLights,
/// Brakes' temperature values in degrees Celsius.
/// See [`wheel_index`](mod@crate::constants::wheel_index)

View File

@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
#[non_exhaustive]
#[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)]
#[br(little, import(_packet_format: u16))]
pub enum EventDataDetails {
pub enum EventDetails {
/// Sent when the session starts.
#[br(magic = b"SSTA")]
SessionStarted,
@ -130,7 +130,7 @@ pub enum EventDataDetails {
#[br(magic = b"BUTN")]
Buttons {
/// Bitmap specifying which buttons are currently pressed.
#[br(map(ButtonStatus::from_bits_truncate))]
#[br(map(ButtonStatus::from_bits_retain))]
button_status: ButtonStatus,
},
/// Sent when a car has overtaken another.
@ -154,9 +154,9 @@ pub enum EventDataDetails {
Collision {
/// Index of the first vehicle involved in the collision.
#[br(map(u8_to_usize))]
vehicle1_index: usize,
vehicle_index: usize,
/// Index of the second vehicle involved in the collision.
#[br(map(u8_to_usize))]
vehicle2_index: usize,
other_vehicle_index: usize,
},
}

View File

@ -35,7 +35,7 @@ pub struct LapHistoryData {
#[br(if(packet_format >= 2023))]
pub sector3_time_minutes: u8,
/// Bitmap of lap validity across all sectors and overall.
#[br(map(LapValid::from_bits_truncate))]
#[br(map(LapValid::from_bits_retain))]
pub lap_valid_bit_flags: LapValid,
}