From: Ian Jackson Date: Sat, 13 Mar 2021 15:54:44 +0000 (+0000) Subject: apitest: Introduce JsV type X-Git-Tag: otter-0.4.0~118 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2a5169d4c94b99fbba76d46743fe779c5ef9149f;p=otter.git apitest: Introduce JsV type Signed-off-by: Ian Jackson --- diff --git a/apitest.rs b/apitest.rs index 0138efc2..2765c86a 100644 --- a/apitest.rs +++ b/apitest.rs @@ -18,6 +18,7 @@ pub use num_traits::NumCast; pub use serde_json::json; pub use structopt::StructOpt; +pub type JsV = serde_json::Value; pub type MC = MgmtCommand; // -------------------- private imports ---------- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 4c2aefb0..5dad940a 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -104,7 +104,7 @@ mod scraper_ext { use scraper_ext::{HtmlExt, RequestBuilderExt}; -type Update = serde_json::Value; +type Update = JsV; #[throws(AE)] fn updates_parser(input: R, out: &mut mpsc::Sender) { @@ -207,7 +207,7 @@ struct PieceInfo { impl Session { #[throws(AE)] - fn pieces(&self) -> Vec> { + fn pieces(&self) -> Vec> { self.dom .element("#pieces_marker") .unwrap().next_siblings() @@ -230,7 +230,7 @@ impl Session { #[throws(AE)] fn api_piece_op(&mut self, piece: &str, opname: &str, - op: serde_json::Value) { + op: JsV) { self.cseq += 1; let cseq = self.cseq; @@ -250,7 +250,7 @@ impl Session { #[throws(AE)] fn api_with_piece_op(&mut self, piece: &str, - pathfrag: &str, op: serde_json::Value) { + pathfrag: &str, op: JsV) { self.api_piece_op(piece, "grab", json!({}))?; self.api_piece_op(piece, pathfrag, op)?; self.api_piece_op(piece, "ungrab", json!({}))?; @@ -258,7 +258,7 @@ impl Session { #[throws(AE)] fn api_with_piece_op_synch(&mut self, piece: &str, - pathfrag: &str, op: serde_json::Value) { + pathfrag: &str, op: JsV) { self.api_piece_op(piece, "grab", json!({}))?; self.api_piece_op(piece, pathfrag, op)?; self.synch()?; @@ -268,9 +268,9 @@ impl Session { #[throws(AE)] fn await_update< R, - F: FnMut(&mut Session, Generation, &str, &serde_json::Value) -> Option, + F: FnMut(&mut Session, Generation, &str, &JsV) -> Option, G: FnMut(&mut Session, Generation) -> Option, - E: FnMut(&mut Session, Generation, &serde_json::Value) + E: FnMut(&mut Session, Generation, &JsV) -> Result, AE> > (&mut self, mut g: G, mut f: F, mut ef: Option) -> R { 'overall: loop { @@ -300,9 +300,9 @@ impl Session { #[throws(AE)] fn synchx< - F: FnMut(&mut Session, Generation, &str, &serde_json::Value), + F: FnMut(&mut Session, Generation, &str, &JsV), > (&mut self, - ef: Option<&mut dyn FnMut(&mut Session, Generation, &serde_json::Value) + ef: Option<&mut dyn FnMut(&mut Session, Generation, &JsV) -> Result<(), AE>>, mut f: F) { diff --git a/wdriver.rs b/wdriver.rs index bc838470..46ea76c0 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -162,7 +162,7 @@ fn fetch_log(driver: &T4d, name: &str) { .ok_or(anyhow!("saved isn't an array?"))? { #[derive(Deserialize)] - struct LogEnt(String, Vec); + struct LogEnt(String, Vec); impl fmt::Display for LogEnt { #[throws(fmt::Error)] fn fmt(&self, f: &mut fmt::Formatter) { @@ -233,8 +233,8 @@ impl<'g> WindowGuard<'g> { let held = held.value(); dbg!(held); match held { - serde_json::Value::Null => None, - serde_json::Value::String(s) => Some(s.to_owned()), + JsV::Null => None, + JsV::String(s) => Some(s.to_owned()), _ => Err(anyhow!("held check script gave {:?}", held))?, } }