Lap

Struct Lap 

Source
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

Source

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

Source

pub fn last_lap_time(&self) -> &Duration

Returns the time of the last lap.

Source

pub fn current_lap_time(&self) -> &Duration

Returns the time of the current lap.

Source

pub fn best_lap_time(&self) -> &Duration

Returns the time of the best lap.

Source

pub fn sector1_time(&self) -> &Duration

Returns the time spent in sector 1 during the current lap.

Source

pub fn sector2_time(&self) -> &Duration

Returns the time spent in sector 2 during the current lap.

Source

pub fn safety_car_delta(&self) -> &Duration

Returns the delta during a safety car in seconds.

Source§

impl Lap

Source

pub fn lap_distance(&self) -> f32

Returns the distance the car has travelled in the current lap in meters.

Source

pub fn total_distance(&self) -> f32

Returns the total distance the car has travelled in the session in meters.

Source

pub fn position(&self) -> u8

Returns a car’s position in the race.

Source

pub fn current_lap_number(&self) -> u8

Returns the number of the current lap.

Source

pub fn pit_status(&self) -> PitStatus

Returns a car’s pit stop status.

Source

pub fn sector(&self) -> Sector

Returns the sector the car is currently in.

Source

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.

Source

pub fn penalties(&self) -> u8

Returns the accumulated penalties for a car in seconds.

Source

pub fn grid_position(&self) -> u8

Returns the grid position the car started the race in.

Source

pub fn driver_status(&self) -> DriverStatus

Returns the status of the driver.

Source

pub fn result_status(&self) -> ResultStatus

Returns the status of the race results.

Trait Implementations§

Source§

impl Clone for Lap

Source§

fn clone(&self) -> Lap

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Lap

Source§

fn default() -> Lap

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Lap

Source§

fn eq(&self, other: &Lap) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Lap

Source§

fn partial_cmp(&self, other: &Lap) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Lap

Source§

impl StructuralPartialEq for Lap

Auto Trait Implementations§

§

impl Freeze for Lap

§

impl RefUnwindSafe for Lap

§

impl Send for Lap

§

impl Sync for Lap

§

impl Unpin for Lap

§

impl UnwindSafe for Lap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.