chiark / gitweb /
Add an UnpreparedUpdates to PieceUpdateFromOpComplex
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 15:08:23 +0000 (15:08 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 19:51:57 +0000 (19:51 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/api.rs
src/hand.rs
src/updates.rs

index 50e8e94ca2a1743d558a6e69d9fa8bc07ba2e290..907c71f6ba2441fa18cb0c549015af43e885977b 100644 (file)
@@ -60,7 +60,7 @@ mod op {
   impl<T> Complex for T where T: Core + Simple {
     #[throws(ApiPieceOpError)]
     fn op_complex(&self, a: ApiPieceOpArgs) -> UpdateFromOpComplex {
-      (self.op(a)?, vec![])
+      (self.op(a)?, vec![], None)
     }
   }
 }
@@ -162,7 +162,7 @@ fn api_piece_op<O: op::Complex>(form: Json<ApiPiece<O>>)
       warn!("api_piece_op ERROR {:?}: {:?}", &form, &err);
       Err(err)?;
     },
-    Ok((PieceUpdate { wrc, log, ops }, updates)) => {
+    Ok((PieceUpdate { wrc, log, ops }, updates, unprepared)) => {
       let mut buf = PrepareUpdatesBuffer::new(g,
                                               Some((wrc, client, form.cseq)),
                                               Some(1 + log.len()));
@@ -170,6 +170,7 @@ fn api_piece_op<O: op::Complex>(form: Json<ApiPiece<O>>)
       buf.piece_update(piece, ops);
       buf.piece_updates(updates);
       buf.log_updates(log);
+      if let Some(unprepared) = unprepared { unprepared(&mut buf); }
 
       debug!("api_piece_op OK: {:?}", &form);
     }
@@ -519,7 +520,7 @@ api_route!{
               wrc,
               PieceUpdateOp::Modify(()),
               logents,
-            ).into(), vec![])
+            ).into(), vec![], None)
           },
 
           _ => break,
index 755a95d821d20a590f714c5a6a651665e5ec4596..b5829107b5d634c1ca10d739fc8bc41774c08575 100644 (file)
@@ -240,6 +240,6 @@ impl PieceTrait for Hand {
       wrc, log,
       ops: PUOs::Simple(PUO::Modify(())), // xxx
       // xxx want PUU::RecalculateOccultations
-    }, xupdates)
+    }, xupdates, None)
   }
 }
index 265ae6a5a4c24e61b1d837292a9be189f4c94765..4caeb8946ef2d49399c2ab33af218ea0af927ef6 100644 (file)
@@ -150,7 +150,11 @@ pub enum PieceUpdateOp<NS,ZL> {
   SetZLevel(ZL),
 }
 
-pub type UpdateFromOpComplex = (PieceUpdate, Vec<(PieceId, PieceUpdateOps)>);
+pub type UpdateFromOpComplex = (
+  PieceUpdate,
+  Vec<(PieceId, PieceUpdateOps)>,
+  UnpreparedUpdates,
+);
 
 pub type PieceUpdateFromOpSimple = (
   WhatResponseToClientOp,