Skip to main content

Crate f1_game_library_models_25

Crate f1_game_library_models_25 

Source
Expand description

§F1 Game Library Models 25

Data types and zero-copy deserialization for the UDP telemetry packets emitted by EA Sports F1 25. Based on the official UDP specification. Previous game versions are not supported.

§Quick start

use f1_game_library_models_25::parse;

fn handle(buf: &[u8]) {
    match parse::parse(buf) {
        Ok(packet) => println!("{packet:?}"),
        Err(e) => eprintln!("parse error: {e}"),
    }
}

§UDP client

Enable the client feature for a ready-made async listener:

use f1_game_library_models_25::client::{TelemetryClient, HandlePacket, TelemetryControl};
use f1_game_library_models_25::packets::lap_data::PacketLapData;

struct MyHandler;

impl HandlePacket for MyHandler {
    async fn handle_lap_data(&mut self, p: PacketLapData) -> anyhow::Result<TelemetryControl> {
        let frame = p.header.frame_identifier();
        println!("lap data frame {frame}");
        Ok(TelemetryControl::Continue)
    }
}

#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
    TelemetryClient::new("0.0.0.0:20777").await?.listen(&mut MyHandler).await
}

§Disclaimer

Not affiliated with Formula 1, the FIA, any F1 team, or EA/Codemasters. Team names and identifiers are derived from the publicly available UDP specification and are used solely for data interoperability.

Re-exports§

pub use endian::FixEndianness;
pub use parse::parse;
pub use wheel_data::WheelData;

Modules§

client
UDP telemetry client for the v2 packet model.
constants
endian
enums
macros
packet_id
packets
parse
wheel_data

Structs§

Packet
A typed UDP packet: the 29-byte wire header followed by a packet-specific payload.
PacketHeader
Wire-format packet header — the 29-byte prefix common to every packet.