From d999f4b56803b613dcf354862e1db4b5d2a8a8d0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Aug 2018 12:04:33 +0300 Subject: cancelation --- crates/server/src/dispatch.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'crates/server/src/dispatch.rs') diff --git a/crates/server/src/dispatch.rs b/crates/server/src/dispatch.rs index d8cca48d0..806534944 100644 --- a/crates/server/src/dispatch.rs +++ b/crates/server/src/dispatch.rs @@ -58,20 +58,18 @@ fn parse_request_as(raw: RawRequest) Ok(Ok((params, responder))) } -pub fn handle_request(req: &mut Option, f: F) -> Result<()> +pub fn handle_request(req: RawRequest, f: F) -> Result<::std::result::Result> where R: ClientRequest, F: FnOnce(R::Params, Responder) -> Result<()> { - match req.take() { - None => Ok(()), - Some(r) => match parse_request_as::(r)? { - Ok((params, responder)) => f(params, responder), - Err(r) => { - *req = Some(r); - Ok(()) - } - } + let id = req.id; + match parse_request_as::(req)? { + Ok((params, responder)) => { + let () = f(params, responder)?; + Ok(Ok(id)) + }, + Err(r) => Ok(Err(r)), } } -- cgit v1.2.3