mirror of
https://github.com/maciejpedzich/f1-game-packet-parser.git
synced 2025-04-20 03:21:12 +02:00
docs: convert inline code block field names to proper field links
This commit is contained in:
parent
57a1215249
commit
e28e5f2795
@ -45,6 +45,7 @@ use crate::packets::tyre_sets::{TyreSetData, NUM_TYRE_SETS};
|
|||||||
|
|
||||||
use binrw::BinRead;
|
use binrw::BinRead;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::fmt;
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
/// Physics data for all the cars being driven.
|
/// Physics data for all the cars being driven.
|
||||||
@ -112,7 +113,8 @@ pub struct F1PacketSession {
|
|||||||
)]
|
)]
|
||||||
pub num_marshal_zones: usize,
|
pub num_marshal_zones: usize,
|
||||||
/// List of marshal zones.
|
/// List of marshal zones.
|
||||||
/// Has a size equal to `num_marshal_zones`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_marshal_zones`](field@crate::packets::F1PacketSession::num_marshal_zones).
|
||||||
#[br(
|
#[br(
|
||||||
count(num_marshal_zones),
|
count(num_marshal_zones),
|
||||||
args{ inner: (packet_format,) },
|
args{ inner: (packet_format,) },
|
||||||
@ -137,7 +139,8 @@ pub struct F1PacketSession {
|
|||||||
)]
|
)]
|
||||||
pub num_weather_forecast_samples: usize,
|
pub num_weather_forecast_samples: usize,
|
||||||
/// List of up to weather forecast samples.
|
/// List of up to weather forecast samples.
|
||||||
/// Has a size equal to `num_weather_forecast_samples`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_weather_forecast_samples`](field@crate::packets::F1PacketSession::num_weather_forecast_samples).
|
||||||
#[br(
|
#[br(
|
||||||
count(num_weather_forecast_samples),
|
count(num_weather_forecast_samples),
|
||||||
args{ inner: (packet_format,) },
|
args{ inner: (packet_format,) },
|
||||||
@ -336,6 +339,8 @@ pub struct F1PacketSession {
|
|||||||
)]
|
)]
|
||||||
pub num_sessions_in_weekend: usize,
|
pub num_sessions_in_weekend: usize,
|
||||||
/// List of sessions that shows this weekend's structure.
|
/// List of sessions that shows this weekend's structure.
|
||||||
|
/// Should have a size equal to
|
||||||
|
/// [`num_sessions_in_weekend`](field@crate::packets::F1PacketSession::num_sessions_in_weekend).
|
||||||
/// Available from the 2024 format onwards.
|
/// Available from the 2024 format onwards.
|
||||||
#[br(
|
#[br(
|
||||||
if(packet_format >= 2024),
|
if(packet_format >= 2024),
|
||||||
@ -402,7 +407,8 @@ pub struct F1PacketParticipants {
|
|||||||
#[br(map(u8_to_usize))]
|
#[br(map(u8_to_usize))]
|
||||||
pub num_active_cars: usize,
|
pub num_active_cars: usize,
|
||||||
/// Data for all participants.
|
/// Data for all participants.
|
||||||
/// Should have a size equal to `num_cars`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_active_cars`](field@crate::packets::F1PacketParticipants::num_active_cars).
|
||||||
#[br(count(num_active_cars), args{ inner: (packet_format,) })]
|
#[br(count(num_active_cars), args{ inner: (packet_format,) })]
|
||||||
pub participants_data: Vec<ParticipantsData>,
|
pub participants_data: Vec<ParticipantsData>,
|
||||||
}
|
}
|
||||||
@ -472,7 +478,8 @@ pub struct F1PacketFinalClassification {
|
|||||||
)]
|
)]
|
||||||
pub num_cars: usize,
|
pub num_cars: usize,
|
||||||
/// Final classification data for all cars.
|
/// Final classification data for all cars.
|
||||||
/// Should have a size equal to `num_cars`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_cars`](field@crate::packets::F1PacketFinalClassification::num_cars).
|
||||||
#[br(count(num_cars), args{ inner: (packet_format,) })]
|
#[br(count(num_cars), args{ inner: (packet_format,) })]
|
||||||
pub final_classification_data: Vec<FinalClassificationData>,
|
pub final_classification_data: Vec<FinalClassificationData>,
|
||||||
}
|
}
|
||||||
@ -493,7 +500,8 @@ pub struct F1PacketLobbyInfo {
|
|||||||
)]
|
)]
|
||||||
pub num_players: usize,
|
pub num_players: usize,
|
||||||
/// Lobby info data for all players.
|
/// Lobby info data for all players.
|
||||||
/// Should have a size equal to `num_players`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_players`](field@crate::packets::F1PacketLobbyInfo::num_players).
|
||||||
#[br(count(num_players), args{ inner: (packet_format,) })]
|
#[br(count(num_players), args{ inner: (packet_format,) })]
|
||||||
pub lobby_info_data: Vec<LobbyInfoData>,
|
pub lobby_info_data: Vec<LobbyInfoData>,
|
||||||
}
|
}
|
||||||
@ -555,8 +563,8 @@ pub struct F1PacketSessionHistory {
|
|||||||
/// Number of the lap the best sector 3 time was achieved on.
|
/// Number of the lap the best sector 3 time was achieved on.
|
||||||
#[br(map(u8_to_usize))]
|
#[br(map(u8_to_usize))]
|
||||||
pub best_sector3_lap_num: usize,
|
pub best_sector3_lap_num: usize,
|
||||||
/// Lap history.
|
/// Lap history. Should have a size equal to
|
||||||
/// Should have a size equal to `num_laps`.
|
/// [`num_laps`](field@crate::packets::F1PacketSessionHistory::num_laps).
|
||||||
#[br(
|
#[br(
|
||||||
count(num_laps),
|
count(num_laps),
|
||||||
args{ inner: (packet_format,) },
|
args{ inner: (packet_format,) },
|
||||||
@ -564,7 +572,8 @@ pub struct F1PacketSessionHistory {
|
|||||||
)]
|
)]
|
||||||
pub lap_history_data: Vec<LapHistoryData>,
|
pub lap_history_data: Vec<LapHistoryData>,
|
||||||
/// Tyre stint history.
|
/// Tyre stint history.
|
||||||
/// Should have a size equal to `num_tyre_stints`.
|
/// Should have a size equal to
|
||||||
|
/// [`num_tyre_stints`](field@crate::packets::F1PacketSessionHistory::num_tyre_stints).
|
||||||
#[br(count(num_tyre_stints), args{ inner: (packet_format,) })]
|
#[br(count(num_tyre_stints), args{ inner: (packet_format,) })]
|
||||||
pub tyre_stint_history_data: Vec<TyreStintHistoryData>,
|
pub tyre_stint_history_data: Vec<TyreStintHistoryData>,
|
||||||
}
|
}
|
||||||
@ -707,19 +716,19 @@ pub struct F1PacketTimeTrial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub(crate) struct InvalidBoolValue(u8);
|
pub(crate) struct InvalidBool(u8);
|
||||||
|
|
||||||
impl core::fmt::Display for InvalidBoolValue {
|
impl fmt::Display for InvalidBool {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Invalid bool value: {}", self.0)
|
write!(f, "Invalid bool value: {}", self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn u8_to_bool(value: u8) -> Result<bool, InvalidBoolValue> {
|
pub(crate) fn u8_to_bool(value: u8) -> Result<bool, InvalidBool> {
|
||||||
match value {
|
match value {
|
||||||
0 => Ok(false),
|
0 => Ok(false),
|
||||||
1 => Ok(true),
|
1 => Ok(true),
|
||||||
_ => Err(InvalidBoolValue(value)),
|
_ => Err(InvalidBool(value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user