From 9f6bab6010abb26814d6d7a163db24fa5965d09c Mon Sep 17 00:00:00 2001 From: Gurwinder Singh Date: Sat, 4 Jan 2020 15:50:52 +0530 Subject: Use async at places, use &self instead of self: &Self (#3594) --- cli/ops/workers.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'cli/ops/workers.rs') diff --git a/cli/ops/workers.rs b/cli/ops/workers.rs index 48b8deb15..00043ce77 100644 --- a/cli/ops/workers.rs +++ b/cli/ops/workers.rs @@ -77,13 +77,11 @@ fn op_worker_get_message( state: state.clone(), }; - let op = op.then(move |maybe_buf| { + let op = async move { + let maybe_buf = op.await; debug!("op_worker_get_message"); - - futures::future::ok(json!({ - "data": maybe_buf.map(|buf| buf) - })) - }); + Ok(json!({ "data": maybe_buf })) + }; Ok(JsonOp::Async(op.boxed())) } @@ -255,14 +253,12 @@ fn op_host_get_message( let mut table = state.workers.lock().unwrap(); // TODO: don't return bad resource anymore let worker = table.get_mut(&id).ok_or_else(bad_resource)?; - let op = worker - .get_message() - .map_err(move |_| -> ErrBox { unimplemented!() }) - .and_then(move |maybe_buf| { - futures::future::ok(json!({ - "data": maybe_buf.map(|buf| buf) - })) - }); + let fut = worker.get_message(); + + let op = async move { + let maybe_buf = fut.await.unwrap(); + Ok(json!({ "data": maybe_buf })) + }; Ok(JsonOp::Async(op.boxed())) } -- cgit v1.2.3