#[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
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
impl TimeConfig
Sourcepub fn new(unit: TimeUnit) -> Self
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));Sourcepub const fn with_total_time(self, units: u64) -> Self
pub const fn with_total_time(self, units: u64) -> Self
Sets Total_Time.
Sourcepub const fn with_byoyomi(self, units: u64) -> Self
pub const fn with_byoyomi(self, units: u64) -> Self
Sets Byoyomi.
Sourcepub const fn with_increment(self, units: u64) -> Self
pub const fn with_increment(self, units: u64) -> Self
Sets Increment.
Sourcepub const fn with_delay(self, units: u64) -> Self
pub const fn with_delay(self, units: u64) -> Self
Sets Delay.
Sourcepub const fn with_least_time_per_move(self, units: u64) -> Self
pub const fn with_least_time_per_move(self, units: u64) -> Self
Sets Least_Time_Per_Move.
Sourcepub const fn with_time_roundup(self, roundup: bool) -> Self
pub const fn with_time_roundup(self, roundup: bool) -> Self
Sets Time_Roundup.
Sourcepub const fn with_remaining_time(self, units: u64) -> Self
pub const fn with_remaining_time(self, units: u64) -> Self
Sets Remaining_Time.
Sourcepub fn eq_ignoring_remaining(&self, other: &Self) -> bool
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.