diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 20:31:34 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 20:31:34 +0100 |
commit | 5475da8ea8184f60b0c54586668f204fe68d1113 (patch) | |
tree | 8f3de5232a818175d080baef05a149a73b1d0bf5 /src/api/common/generic_server.rs | |
parent | 620dc58560c7e1509ee9e56ce03d15ec502c34c8 (diff) | |
download | garage-5475da8ea8184f60b0c54586668f204fe68d1113.tar.gz garage-5475da8ea8184f60b0c54586668f204fe68d1113.zip |
remove async_trait used in generic_server.rs
Diffstat (limited to 'src/api/common/generic_server.rs')
-rw-r--r-- | src/api/common/generic_server.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/api/common/generic_server.rs b/src/api/common/generic_server.rs index d92a3465..6ddc2ff2 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -4,8 +4,6 @@ use std::os::unix::fs::PermissionsExt; use std::sync::Arc; use std::time::Duration; -use async_trait::async_trait; - use futures::future::Future; use futures::stream::{futures_unordered::FuturesUnordered, StreamExt}; @@ -47,7 +45,6 @@ pub trait ApiError: std::error::Error + Send + Sync + 'static { fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody; } -#[async_trait] pub trait ApiHandler: Send + Sync + 'static { const API_NAME: &'static str; const API_NAME_DISPLAY: &'static str; @@ -56,11 +53,11 @@ pub trait ApiHandler: Send + Sync + 'static { type Error: ApiError; fn parse_endpoint(&self, r: &Request<IncomingBody>) -> Result<Self::Endpoint, Self::Error>; - async fn handle( + fn handle( &self, req: Request<IncomingBody>, endpoint: Self::Endpoint, - ) -> Result<Response<BoxBody<Self::Error>>, Self::Error>; + ) -> impl Future<Output = Result<Response<BoxBody<Self::Error>>, Self::Error>> + Send; } pub struct ApiServer<A: ApiHandler> { @@ -248,13 +245,11 @@ impl<A: ApiHandler> ApiServer<A> { // ==== helper functions ==== -#[async_trait] pub trait Accept: Send + Sync + 'static { type Stream: AsyncRead + AsyncWrite + Send + Sync + 'static; - async fn accept(&self) -> std::io::Result<(Self::Stream, String)>; + fn accept(&self) -> impl Future<Output = std::io::Result<(Self::Stream, String)>> + Send; } -#[async_trait] impl Accept for TcpListener { type Stream = TcpStream; async fn accept(&self) -> std::io::Result<(Self::Stream, String)> { @@ -266,7 +261,6 @@ impl Accept for TcpListener { pub struct UnixListenerOn(pub UnixListener, pub String); -#[async_trait] impl Accept for UnixListenerOn { type Stream = UnixStream; async fn accept(&self) -> std::io::Result<(Self::Stream, String)> { |