pub struct Lap { /* private fields */ }
Expand description
Data about a car and its lap times
For each car in the session, a set of lap data is published. It contains data on the current lap, e.g. the current lap time and the sector the car is currently in, but also the time of the last and best lap.
Implementations§
Source§impl Lap
impl Lap
Sourcepub fn new(
last_lap_time: Duration,
current_lap_time: Duration,
best_lap_time: Duration,
sector1_time: Duration,
sector2_time: Duration,
lap_distance: f32,
total_distance: f32,
safety_car_delta: Duration,
position: u8,
current_lap_number: u8,
pit_status: PitStatus,
sector: Sector,
is_valid_lap: bool,
penalties: u8,
grid_position: u8,
driver_status: DriverStatus,
result_status: ResultStatus,
) -> Self
pub fn new( last_lap_time: Duration, current_lap_time: Duration, best_lap_time: Duration, sector1_time: Duration, sector2_time: Duration, lap_distance: f32, total_distance: f32, safety_car_delta: Duration, position: u8, current_lap_number: u8, pit_status: PitStatus, sector: Sector, is_valid_lap: bool, penalties: u8, grid_position: u8, driver_status: DriverStatus, result_status: ResultStatus, ) -> Self
Constructs a new Lap
.
Source§impl Lap
impl Lap
Sourcepub fn last_lap_time(&self) -> &Duration
pub fn last_lap_time(&self) -> &Duration
Returns the time of the last lap.
Sourcepub fn current_lap_time(&self) -> &Duration
pub fn current_lap_time(&self) -> &Duration
Returns the time of the current lap.
Sourcepub fn best_lap_time(&self) -> &Duration
pub fn best_lap_time(&self) -> &Duration
Returns the time of the best lap.
Sourcepub fn sector1_time(&self) -> &Duration
pub fn sector1_time(&self) -> &Duration
Returns the time spent in sector 1 during the current lap.
Sourcepub fn sector2_time(&self) -> &Duration
pub fn sector2_time(&self) -> &Duration
Returns the time spent in sector 2 during the current lap.
Sourcepub fn safety_car_delta(&self) -> &Duration
pub fn safety_car_delta(&self) -> &Duration
Returns the delta during a safety car in seconds.
Source§impl Lap
impl Lap
Sourcepub fn lap_distance(&self) -> f32
pub fn lap_distance(&self) -> f32
Returns the distance the car has travelled in the current lap in meters.
Sourcepub fn total_distance(&self) -> f32
pub fn total_distance(&self) -> f32
Returns the total distance the car has travelled in the session in meters.
Sourcepub fn current_lap_number(&self) -> u8
pub fn current_lap_number(&self) -> u8
Returns the number of the current lap.
Sourcepub fn pit_status(&self) -> PitStatus
pub fn pit_status(&self) -> PitStatus
Returns a car’s pit stop status.
Sourcepub fn is_valid_lap(&self) -> bool
pub fn is_valid_lap(&self) -> bool
Returns whether the current lap is valid.
The F1 games apply different rules to determine if a lap is valid. Cutting the track, losing control, or hitting objects or opponents can all invalidate a lap. This is crucial for qualifying, where invalid laps might not count for the results.
Sourcepub fn grid_position(&self) -> u8
pub fn grid_position(&self) -> u8
Returns the grid position the car started the race in.
Sourcepub fn driver_status(&self) -> DriverStatus
pub fn driver_status(&self) -> DriverStatus
Returns the status of the driver.
Sourcepub fn result_status(&self) -> ResultStatus
pub fn result_status(&self) -> ResultStatus
Returns the status of the race results.