From ff00c35b099eb4d23e0d65476684d7fed7fcf36a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Mar 2021 16:40:21 +0000 Subject: [PATCH] at: impl PieceSpecForOp for () Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index bc6e3113..f294680d 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -247,7 +247,7 @@ impl Session { #[throws(AE)] fn api_piece_op_single(&mut self, piece: &str, o: O) { - let (opname, payload) = o.api(); + let (opname, payload) = if let Some(o) = o.api() { o } else { return }; self.cseq += 1; let cseq = self.cseq; @@ -406,16 +406,20 @@ pub fn update_update_pieces( pub type PieceOpData = (&'static str, JsV); pub trait PieceOp: Debug { - fn api(&self) -> PieceOpData; + fn api(&self) -> Option; fn update(&self, pi: &mut PieceInfo) { info!("no update {:?}", self) } } impl PieceOp for PieceOpData { - fn api(&self) -> PieceOpData { (self.0, self.1.clone()) } + fn api(&self) -> Option { Some((self.0, self.1.clone())) } } impl PieceOp for Pos { - fn api(&self) -> PieceOpData { ("m", json![self.0]) } + fn api(&self) -> Option { Some(("m", json![self.0])) } fn update(&self, pi: &mut PieceInfo) { pi.pos = *self } } +impl PieceOp for () { + fn api(&self) -> Option { None } + fn update(&self, pi: &mut PieceInfo) { } +} pub trait PieceSpecForOp: Debug { fn id(&self) -> &str; -- 2.30.2