Skip to main content

TimeConfig

Struct TimeConfig 

Source
#[non_exhaustive]
pub struct TimeConfig { pub time_unit: Option<TimeUnit>, pub total_time: Option<u64>, pub byoyomi: Option<u64>, pub delay: Option<u64>, pub increment: Option<u64>, pub least_time_per_move: Option<u64>, pub time_roundup: Option<bool>, pub remaining_time: Option<u64>, pub extras: Vec<(String, String)>, }
Expand description

The time control of one side, as declared in a BEGIN Time block.

All durations are in Time_Unit units, exactly as they appear on the wire. Converting to milliseconds is the caller’s job, because only the caller knows whether it wants to apply a safety margin.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§time_unit: Option<TimeUnit>

Time_Unit

§total_time: Option<u64>

Total_Time

§byoyomi: Option<u64>

Byoyomi

§delay: Option<u64>

Delay

§increment: Option<u64>

Increment, granted up front by the server.

§least_time_per_move: Option<u64>

Least_Time_Per_Move

§time_roundup: Option<bool>

Time_Roundup

§remaining_time: Option<u64>

Remaining_Time+ or Remaining_Time-, present only in %%SHOW output.

§extras: Vec<(String, String)>

Unrecognized Key:Value pairs, kept in wire order.

Implementations§

Source§

impl TimeConfig

Source

pub fn new(unit: TimeUnit) -> Self

A control that declares only its time unit.

The type is #[non_exhaustive] because CSA can add time fields, so it is built with these rather than with a struct literal.

use rsshogi_csa::{TimeConfig, TimeUnit};

let control = TimeConfig::new(TimeUnit::SECOND).with_total_time(900).with_byoyomi(10);
assert_eq!(control.total_time, Some(900));
assert_eq!(control.byoyomi, Some(10));
Source

pub const fn with_total_time(self, units: u64) -> Self

Sets Total_Time.

Source

pub const fn with_byoyomi(self, units: u64) -> Self

Sets Byoyomi.

Source

pub const fn with_increment(self, units: u64) -> Self

Sets Increment.

Source

pub const fn with_delay(self, units: u64) -> Self

Sets Delay.

Source

pub const fn with_least_time_per_move(self, units: u64) -> Self

Sets Least_Time_Per_Move.

Source

pub const fn with_time_roundup(self, roundup: bool) -> Self

Sets Time_Roundup.

Source

pub const fn with_remaining_time(self, units: u64) -> Self

Sets Remaining_Time.

Source

pub fn eq_ignoring_remaining(&self, other: &Self) -> bool

Whether two sides declare the same control, ignoring remaining time.

shogi-server sends one shared BEGIN Time block, so this is what decides whether GameSummary::to_lines emits a shared or split block.

Source

pub fn unit(&self) -> TimeUnit

The declared time unit, defaulting to one second when absent.

Source§

impl TimeConfig

Source

pub fn is_empty(&self) -> bool

Whether no field of this time control was declared.

Trait Implementations§

Source§

impl Clone for TimeConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeConfig

Source§

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

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

impl Default for TimeConfig

Source§

fn default() -> Self

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

impl Eq for TimeConfig

Source§

impl PartialEq for TimeConfig

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TimeConfig

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.