diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-02 17:04:50 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-02 17:04:50 +0200 |
commit | 81e647e8818590a5589803cd810ff3018698e786 (patch) | |
tree | da1c1771843d442956d363a9fb2ef87b20a75eb6 | |
parent | 2d1e6bfffbe0579397b4a045acc5014afc508f65 (diff) | |
download | aerogramme-81e647e8818590a5589803cd810ff3018698e786.tar.gz aerogramme-81e647e8818590a5589803cd810ff3018698e786.zip |
Simplified types
-rw-r--r-- | src/server.rs | 16 |
1 files 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<Response> { Ok(Response::ok("Done")?) } -struct Echo; +struct Echo; impl Service<Request> for Echo { type Response = Response; - type Error = Box<dyn Error + Send + Sync>; - type Future = Pin<Box<dyn futures::Future<Output = Result<Self::Response, Self::Error>> + Send>>; + type Error = anyhow::Error; + type Future = Pin<Box<dyn futures::Future<Output = Result<Self::Response>> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { 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<Response, Box<dyn Error + Send + Sync>> { 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<Arc<Self>> { let s3_region = Region::Custom { |