refactor: fix or allow certain pedantic warning from clippy

This commit is contained in:
Maciej Pędzich 2025-02-28 10:48:24 +01:00
parent 7a374cbde7
commit 0f28d8b763
Signed by: maciejpedzich
GPG Key ID: CE4A303D84882F0D
6 changed files with 72 additions and 74 deletions

View File

@ -693,78 +693,78 @@ bitflags! {
impl ButtonStatus: u32 { impl ButtonStatus: u32 {
/// The "A" button on an Xbox controller /// The "A" button on an Xbox controller
/// or the cross button on a PlayStation controller. /// or the cross button on a PlayStation controller.
/// Has a value of `0x00000001`. /// Has a value of `0x0000_0001`.
const A_OR_CROSS = 0x00000001; const A_OR_CROSS = 0x0000_0001;
/// The "Y" button on an Xbox controller /// The "Y" button on an Xbox controller
/// or the triangle button on a PlayStation controller. /// or the triangle button on a PlayStation controller.
/// Has a value of `0x00000002`. /// Has a value of `0x0000_0002`.
const Y_OR_TRIANGLE = 0x00000002; const Y_OR_TRIANGLE = 0x0000_0002;
/// The "B" button on an Xbox controller /// The "B" button on an Xbox controller
/// or the circle button on a PlayStation controller. /// or the circle button on a PlayStation controller.
/// Has a value of `0x00000004`. /// Has a value of `0x0000_0004`.
const B_OR_CIRCLE = 0x00000004; const B_OR_CIRCLE = 0x0000_0004;
/// The "X" button on an Xbox controller /// The "X" button on an Xbox controller
/// or the square button on a PlayStation controller. /// or the square button on a PlayStation controller.
/// Has a value of `0x00000008`. /// Has a value of `0x0000_0008`.
const X_OR_SQUARE = 0x00000008; const X_OR_SQUARE = 0x0000_0008;
/// Left directional pad button. Has a value of `0x00000010`. /// Left directional pad button. Has a value of `0x0000_0010`.
const DPAD_LEFT = 0x00000010; const DPAD_LEFT = 0x0000_0010;
/// Right directional pad button. Has a value of `0x00000020`. /// Right directional pad button. Has a value of `0x0000_0020`.
const DPAD_RIGHT = 0x00000020; const DPAD_RIGHT = 0x0000_0020;
/// Up directional pad button. Has a value of `0x00000040`. /// Up directional pad button. Has a value of `0x0000_0040`.
const DPAD_UP = 0x00000040; const DPAD_UP = 0x0000_0040;
/// Down directional pad button. Has a value of `0x00000080`. /// Down directional pad button. Has a value of `0x0000_0080`.
const DPAD_DOWN = 0x00000080; const DPAD_DOWN = 0x0000_0080;
/// The "Menu" button on an Xbox controller /// The "Menu" button on an Xbox controller
/// or the "Options" button on a PlayStation controller. /// or the "Options" button on a PlayStation controller.
/// Has a value of `0x00000100`. /// Has a value of `0x0000_0100`.
const MENU_OR_OPTIONS = 0x00000100; const MENU_OR_OPTIONS = 0x0000_0100;
/// Left bumper. Has a value of `0x00000200`. /// Left bumper. Has a value of `0x0000_0200`.
const LEFT_BUMPER = 0x00000200; const LEFT_BUMPER = 0x0000_0200;
/// Right bumper. Has a value of `0x00000400`. /// Right bumper. Has a value of `0x0000_0400`.
const RIGHT_BUMPER = 0x00000400; const RIGHT_BUMPER = 0x0000_0400;
/// Left trigger. Has a value of `0x00000800`. /// Left trigger. Has a value of `0x0000_0800`.
const LEFT_TRIGGER = 0x00000800; const LEFT_TRIGGER = 0x0000_0800;
/// Right trigger. Has a value of `0x00001000`. /// Right trigger. Has a value of `0x0000_1000`.
const RIGHT_TRIGGER = 0x00001000; const RIGHT_TRIGGER = 0x0000_1000;
/// Left analog stick click. Has a value of `0x00002000`. /// Left analog stick click. Has a value of `0x0000_2000`.
const LEFT_STICK_CLICK = 0x00002000; const LEFT_STICK_CLICK = 0x0000_2000;
/// Right analog stick click. Has a value of `0x00004000`. /// Right analog stick click. Has a value of `0x0000_4000`.
const RIGHT_STICK_CLICK = 0x00004000; const RIGHT_STICK_CLICK = 0x0000_4000;
/// Right analog stick left. Has a value of `0x00008000`. /// Right analog stick left. Has a value of `0x0000_8000`.
const RIGHT_STICK_LEFT = 0x00008000; const RIGHT_STICK_LEFT = 0x0000_8000;
/// Right analog stick right. Has a value of `0x00010000` /// Right analog stick right. Has a value of `0x0001_0000`
const RIGHT_STICK_RIGHT = 0x00010000; const RIGHT_STICK_RIGHT = 0x0001_0000;
/// Right analog stick up. Has a value of `0x00020000` /// Right analog stick up. Has a value of `0x0002_0000`
const RIGHT_STICK_UP = 0x00020000; const RIGHT_STICK_UP = 0x0002_0000;
/// Right analog stick down. Has a value of `0x00040000` /// Right analog stick down. Has a value of `0x0004_0000`
const RIGHT_STICK_DOWN = 0x00040000; const RIGHT_STICK_DOWN = 0x0004_0000;
/// Special button. Has a value of `0x00080000`. /// Special button. Has a value of `0x0008_0000`.
const SPECIAL = 0x00080000; const SPECIAL = 0x0008_0000;
/// UDP Action 1. Has a value of `0x00100000`. /// UDP Action 1. Has a value of `0x0010_0000`.
const UDP_ACTION_1 = 0x00100000; const UDP_ACTION_1 = 0x0010_0000;
/// UDP Action 2. Has a value of `0x00200000`. /// UDP Action 2. Has a value of `0x0020_0000`.
const UDP_ACTION_2 = 0x00200000; const UDP_ACTION_2 = 0x0020_0000;
/// UDP Action 3. Has a value of `0x00400000`. /// UDP Action 3. Has a value of `0x0040_0000`.
const UDP_ACTION_3 = 0x00400000; const UDP_ACTION_3 = 0x0040_0000;
/// UDP Action 4. Has a value of `0x00800000`. /// UDP Action 4. Has a value of `0x0080_0000`.
const UDP_ACTION_4 = 0x00800000; const UDP_ACTION_4 = 0x0080_0000;
/// UDP Action 5. Has a value of `0x01000000`. /// UDP Action 5. Has a value of `0x0100_0000`.
const UDP_ACTION_5 = 0x01000000; const UDP_ACTION_5 = 0x0100_0000;
/// UDP Action 6. Has a value of `0x02000000`. /// UDP Action 6. Has a value of `0x0200_0000`.
const UDP_ACTION_6 = 0x02000000; const UDP_ACTION_6 = 0x0200_0000;
/// UDP Action 7. Has a value of `0x04000000`. /// UDP Action 7. Has a value of `0x0400_0000`.
const UDP_ACTION_7 = 0x04000000; const UDP_ACTION_7 = 0x0400_0000;
/// UDP Action 8. Has a value of `0x08000000`. /// UDP Action 8. Has a value of `0x0800_0000`.
const UDP_ACTION_8 = 0x08000000; const UDP_ACTION_8 = 0x0800_0000;
/// UDP Action 9. Has a value of `0x10000000`. /// UDP Action 9. Has a value of `0x1000_0000`.
const UDP_ACTION_9 = 0x10000000; const UDP_ACTION_9 = 0x1000_0000;
/// UDP Action 10. Has a value of `0x20000000`. /// UDP Action 10. Has a value of `0x2000_0000`.
const UDP_ACTION_10 = 0x20000000; const UDP_ACTION_10 = 0x2000_0000;
/// UDP Action 11. Has a value of `0x40000000`. /// UDP Action 11. Has a value of `0x4000_0000`.
const UDP_ACTION_11 = 0x40000000; const UDP_ACTION_11 = 0x4000_0000;
/// UDP Action 12. Has a value of `0x80000000`. /// UDP Action 12. Has a value of `0x8000_0000`.
const UDP_ACTION_12 = 0x80000000; const UDP_ACTION_12 = 0x8000_0000;
} }
} }

View File

@ -2,6 +2,7 @@ use super::u8_to_bool;
use binrw::BinRead; use binrw::BinRead;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[allow(clippy::struct_excessive_bools)]
#[non_exhaustive] #[non_exhaustive]
#[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)] #[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)]
#[br(little, import(_packet_format: u16))] #[br(little, import(_packet_format: u16))]

View File

@ -46,36 +46,36 @@ impl CarMotionData {
/// Returns [`world_forward_dir_x`](field@CarMotionData::world_forward_dir_x) /// Returns [`world_forward_dir_x`](field@CarMotionData::world_forward_dir_x)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_forward_dir_x_as_f32(&self) -> f32 { pub fn world_forward_dir_x_as_f32(&self) -> f32 {
self.world_forward_dir_x as f32 / 32767.0 f32::from(self.world_forward_dir_x) / 32767.0
} }
/// Returns [`world_forward_dir_y`](field@CarMotionData::world_forward_dir_y) /// Returns [`world_forward_dir_y`](field@CarMotionData::world_forward_dir_y)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_forward_dir_y_as_f32(&self) -> f32 { pub fn world_forward_dir_y_as_f32(&self) -> f32 {
self.world_forward_dir_y as f32 / 32767.0 f32::from(self.world_forward_dir_y) / 32767.0
} }
/// Returns [`world_forward_dir_z`](field@CarMotionData::world_forward_dir_z) /// Returns [`world_forward_dir_z`](field@CarMotionData::world_forward_dir_z)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_forward_dir_z_as_f32(&self) -> f32 { pub fn world_forward_dir_z_as_f32(&self) -> f32 {
self.world_forward_dir_z as f32 / 32767.0 f32::from(self.world_forward_dir_z) / 32767.0
} }
/// Returns [`world_right_dir_x`](field@CarMotionData::world_right_dir_x) /// Returns [`world_right_dir_x`](field@CarMotionData::world_right_dir_x)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_right_dir_x_as_f32(&self) -> f32 { pub fn world_right_dir_x_as_f32(&self) -> f32 {
self.world_right_dir_x as f32 / 32767.0 f32::from(self.world_right_dir_x) / 32767.0
} }
/// Returns [`world_right_dir_y`](field@CarMotionData::world_right_dir_y) /// Returns [`world_right_dir_y`](field@CarMotionData::world_right_dir_y)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_right_dir_y_as_f32(&self) -> f32 { pub fn world_right_dir_y_as_f32(&self) -> f32 {
self.world_right_dir_y as f32 / 32767.0 f32::from(self.world_right_dir_y) / 32767.0
} }
/// Returns [`world_right_dir_z`](field@CarMotionData::world_right_dir_z) /// Returns [`world_right_dir_z`](field@CarMotionData::world_right_dir_z)
/// divided by `32767.0f32`. /// divided by `32767.0f32`.
pub fn world_right_dir_z_as_f32(&self) -> f32 { pub fn world_right_dir_z_as_f32(&self) -> f32 {
self.world_right_dir_z as f32 / 32767.0 f32::from(self.world_right_dir_z) / 32767.0
} }
} }

View File

@ -62,12 +62,10 @@ pub struct WeatherForecastSample {
pub rain_percentage: u8, pub rain_percentage: u8,
} }
#[inline(always)]
pub(super) fn check_num_forecast_samples(packet_format: u16, num_samples: usize) -> bool { pub(super) fn check_num_forecast_samples(packet_format: u16, num_samples: usize) -> bool {
num_samples <= get_max_num_samples(packet_format) num_samples <= get_max_num_samples(packet_format)
} }
#[inline(always)]
pub(super) fn get_forecast_samples_padding( pub(super) fn get_forecast_samples_padding(
packet_format: u16, packet_format: u16,
num_samples: usize, num_samples: usize,
@ -75,7 +73,6 @@ pub(super) fn get_forecast_samples_padding(
(get_max_num_samples(packet_format) - num_samples) * FORECAST_SAMPLE_RAW_SIZE (get_max_num_samples(packet_format) - num_samples) * FORECAST_SAMPLE_RAW_SIZE
} }
#[inline(always)]
fn get_max_num_samples(packet_format: u16) -> usize { fn get_max_num_samples(packet_format: u16) -> usize {
if packet_format >= 2024 { if packet_format >= 2024 {
64 64

View File

@ -53,7 +53,6 @@ pub struct TyreStintHistoryData {
pub visual_tyre_compound: VisualTyreCompound, pub visual_tyre_compound: VisualTyreCompound,
} }
#[inline(always)]
pub(super) fn get_lap_history_raw_size(packet_format: u16) -> usize { pub(super) fn get_lap_history_raw_size(packet_format: u16) -> usize {
if packet_format >= 2023 { if packet_format >= 2023 {
14 14

View File

@ -4,6 +4,7 @@ use crate::constants::{GearboxAssist, TractionControl, MAX_NUM_CARS};
use binrw::BinRead; use binrw::BinRead;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[allow(clippy::struct_excessive_bools)]
#[non_exhaustive] #[non_exhaustive]
#[derive( #[derive(
BinRead, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize, BinRead, Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize,