TimedInternalGame

Struct TimedInternalGame 

Source
pub struct TimedInternalGame { /* private fields */ }
Expand description

Game information encompassing

  • The time the game was recorded
  • The TimedInternalRating of the opponent
  • The score as a number between 0.0 (decisive opponent win) and 1.0 (decisive player win)

Keep in mind that this struct does not hold information about the player’s rating, only the opponent’s. This is because it is used to register games on and therefore update the player’s rating struct.

Implementations§

Source§

impl TimedInternalGame

Source

pub fn new(time: SystemTime, opponent: TimedInternalRating, score: f64) -> Self

Creates a new TimedInternalGame at the given time with the given opponent and score. score is a number between 0.0 (decisive opponent win) and 1.0 (decisive player win).

§Panics

This function panics if score is less than 0.0 or greater than 1.0.

Source

pub fn time(&self) -> SystemTime

The time this game was recorded.

Source

pub fn opponent(&self) -> TimedInternalRating

The opponent’s rating.

Source

pub fn score(&self) -> f64

The game score as a number between 0.0 (decisive opponent win) and 1.0 (decisive player win).

Source

pub fn raw_internal_game(&self) -> InternalGame

The game with timing information erased and the opponent’s rating resolved to their rating at the time of the last update.

Source

pub fn to_internal_game(&self, rating_period_duration: Duration) -> InternalGame

Converts this TimedInternalGame to an InternalGame, erasing the timing information and resolving the opponents rating to their rating at the time of the game.

§Panics

This function panics if the opponent rating was updated after the game was recorded, or if the rating_period_duration is zero.

Source

pub fn internal_game_at( &self, time: SystemTime, rating_period_duration: Duration, ) -> InternalGame

Converts this TimedInternalGame to an InternalGame, erasing the timing information and resolving the opponent’s rating to their rating at the given time.

§Panics

This function panics if the given time is before the opponent rating’s last update, or if rating_period_duration is zero.

Trait Implementations§

Source§

impl Clone for TimedInternalGame

Source§

fn clone(&self) -> TimedInternalGame

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 TimedInternalGame

Source§

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

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

impl<'de> Deserialize<'de> for TimedInternalGame

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<TimedInternalGame> for TimedInternalGames

Source§

fn from(game: TimedInternalGame) -> Self

Converts to this type from the input type.
Source§

impl FromWithParameters<TimedInternalGame> for TimedPublicGame

Source§

fn from_with_parameters( internal: TimedInternalGame, parameters: Parameters, ) -> Self

Performs the conversion
Source§

impl FromWithParameters<TimedPublicGame> for TimedInternalGame

Source§

fn from_with_parameters(public: TimedPublicGame, parameters: Parameters) -> Self

Performs the conversion
Source§

impl PartialEq for TimedInternalGame

Source§

fn eq(&self, other: &TimedInternalGame) -> 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 Serialize for TimedInternalGame

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for TimedInternalGame

Source§

impl StructuralPartialEq for TimedInternalGame

Auto Trait Implementations§

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> FromWithParameters<T> for T

Source§

fn from_with_parameters(t: T, _: Parameters) -> T

Performs the conversion
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, U> IntoWithParameters<U> for T
where U: FromWithParameters<T>,

Source§

fn into_with_parameters(self, parameters: Parameters) -> U

Performs the conversion
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,