use scraper_ext::{HtmlExt, RequestBuilderExt};
-type Update = serde_json::Value;
+type Update = JsV;
#[throws(AE)]
fn updates_parser<R:Read>(input: R, out: &mut mpsc::Sender<Update>) {
impl Session {
#[throws(AE)]
- fn pieces(&self) -> Vec<PieceInfo<serde_json::Value>> {
+ fn pieces(&self) -> Vec<PieceInfo<JsV>> {
self.dom
.element("#pieces_marker")
.unwrap().next_siblings()
#[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;
#[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!({}))?;
#[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()?;
#[throws(AE)]
fn await_update<
R,
- F: FnMut(&mut Session, Generation, &str, &serde_json::Value) -> Option<R>,
+ F: FnMut(&mut Session, Generation, &str, &JsV) -> Option<R>,
G: FnMut(&mut Session, Generation) -> Option<R>,
- E: FnMut(&mut Session, Generation, &serde_json::Value)
+ E: FnMut(&mut Session, Generation, &JsV)
-> Result<Option<R>, AE>
> (&mut self, mut g: G, mut f: F, mut ef: Option<E>) -> R {
'overall: loop {
#[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)
{
.ok_or(anyhow!("saved isn't an array?"))?
{
#[derive(Deserialize)]
- struct LogEnt(String, Vec<serde_json::Value>);
+ struct LogEnt(String, Vec<JsV>);
impl fmt::Display for LogEnt {
#[throws(fmt::Error)]
fn fmt(&self, f: &mut fmt::Formatter) {
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))?,
}
}