From 81e647e8818590a5589803cd810ff3018698e786 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 2 Jun 2022 17:04:50 +0200 Subject: Simplified types --- src/server.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/server.rs b/src/server.rs index 46f1f76..e9b05d8 100644 --- a/src/server.rs +++ b/src/server.rs @@ -28,29 +28,25 @@ async fn handle_req(req: Request) -> Result { Ok(Response::ok("Done")?) } -struct Echo; +struct Echo; impl Service for Echo { type Response = Response; - type Error = Box; - type Future = Pin> + Send>>; + type Error = anyhow::Error; + type Future = Pin> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: Request) -> Self::Future { - Box::pin(Echo::handle_req(req)) - } -} - -impl Echo { - async fn handle_req(req: Request) -> Result> { println!("Got request: {:#?}", req); - Ok(Response::ok("Done").unwrap()) + let fut = futures::future::ok(Response::ok("Done").unwrap()); + Box::pin(fut) } } + impl Server { pub fn new(config: Config) -> Result> { let s3_region = Region::Custom { -- cgit v1.2.3