chiark / gitweb /
clock: Tidying, rename Spec
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:34:18 +0000 (21:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:55:05 +0000 (21:55 +0000)
This was very confusing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs

index 04ad0d7100e9c4dcca5d983e6f5c91179082d937..3f3acd3925236c9cd657ed5d5952efe81032f7ba 100644 (file)
@@ -18,14 +18,14 @@ type Time = i32;
 // ==================== state ====================
 
 #[derive(Debug,Clone,Serialize,Deserialize)]
-pub struct ChessClock { // Spec
+pub struct Spec {
   time: Time,
   #[serde(default)] per_move: Time,
 }
 
 #[derive(Debug,Serialize,Deserialize)]
 struct Clock { // PieceTrait
-  spec: ChessClock,
+  spec: Spec,
 }
 
 #[derive(Debug,Serialize,Deserialize)]
@@ -53,19 +53,19 @@ struct Running {
   expires: TimeSpec,
 }
 
-impl ChessClock {
+impl Spec {
   fn initial_time(&self) -> TimeSpec { TVL::seconds(self.time.into()) }
   fn per_move(&self) -> TimeSpec { TVL::seconds(self.per_move.into()) }
 }
 
 impl State {
-  fn new(spec: &ChessClock) -> Self {
+  fn new(spec: &Spec) -> Self {
     let mut state = State::dummy();
     state.reset(spec);
     state
   }
 
-  fn reset(&mut self, spec: &ChessClock) {
+  fn reset(&mut self, spec: &Spec) {
     for ust in &mut self.users {
       ust.remaining = spec.initial_time();
     }
@@ -247,7 +247,7 @@ impl State {
                       was_current: Option<Current>,
                       was_implied_running: Option<User>,
                       held: Option<PlayerId>,
-                      spec: &ChessClock,
+                      spec: &Spec,
                       ig: &InstanceRef) {
     let state = self;
 
@@ -391,8 +391,8 @@ fn unprepared_update(piece: PieceId) -> UnpreparedUpdates {
   }))
 }
 
-#[typetag::serde]
-impl PieceSpec for ChessClock {
+#[typetag::serde(name="ChessClock")]
+impl PieceSpec for Spec {
   #[throws(SpecError)]
   fn load(&self, _: usize, gpc: &mut GPiece, _ir: &InstanceRef)
           -> PieceSpecLoaded {