pub struct Header { /* private fields */ }
Expand description
Header prefixing each packet
The modern F1 games use versioned API specifications. Each packet is prefixed with a header that declares which version of the specification the packet adheres to. This information is required to decode the packet correctly. Because it is only relevant for decoding the packet, the packet format, type, and version from the specifications are not republished.
The header also contains information about the session the packet belongs to, and about the time the packet was created.
TODO Verify that the session tie can be represented as a duration
Implementations§
Source§impl Header
impl Header
Sourcepub fn new(
api_spec: ApiSpec,
game_version: Option<GameVersion>,
packet_type: PacketType,
session_uid: u64,
session_time: Duration,
frame_identifier: u32,
player_car_index: VehicleIndex,
) -> Self
pub fn new( api_spec: ApiSpec, game_version: Option<GameVersion>, packet_type: PacketType, session_uid: u64, session_time: Duration, frame_identifier: u32, player_car_index: VehicleIndex, ) -> Self
Constructs a new Header
.
Source§impl Header
impl Header
Sourcepub fn game_version(&self) -> &Option<GameVersion>
pub fn game_version(&self) -> &Option<GameVersion>
Returns the version of the game.
Sourcepub fn session_time(&self) -> &Duration
pub fn session_time(&self) -> &Duration
Returns the session time at the time the packet was sent.
Source§impl Header
impl Header
Sourcepub fn api_spec(&self) -> ApiSpec
pub fn api_spec(&self) -> ApiSpec
Returns the API specification that was used to decode the packet.
Sourcepub fn packet_type(&self) -> PacketType
pub fn packet_type(&self) -> PacketType
Returns the type of the packet.
The packet type is only required to determine how to decode the packet. After decoding it, the packet type is represented by Rust’s type system.
Sourcepub fn session_uid(&self) -> u64
pub fn session_uid(&self) -> u64
Returns the unique session UID.
Sourcepub fn frame_identifier(&self) -> u32
pub fn frame_identifier(&self) -> u32
Returns the frame identifier at the time the packet was sent.
Sourcepub fn player_car_index(&self) -> VehicleIndex
pub fn player_car_index(&self) -> VehicleIndex
Returns the player’s car index.
The setups and status of cars are published as arrays. This field indicates which position in these arrays the player’s car has.