diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 21:00:19 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-05 21:00:19 +0100 |
commit | 61f3de649646d098812e6ddb814e20ce7e66ad94 (patch) | |
tree | 599160faf816af40b9efcddf14d797fc5ebbcb09 /src/api/common/generic_server.rs | |
parent | 71655c1e89b87fa009d1c5a56448b2fe7df05c49 (diff) | |
parent | d3226bfa91d4500063c5c287c6256729dcbb3f88 (diff) | |
download | garage-61f3de649646d098812e6ddb814e20ce7e66ad94.tar.gz garage-61f3de649646d098812e6ddb814e20ce7e66ad94.zip |
Merge branch 'main' into next-v2next-v2
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 133e3706..d7ee5692 100644 --- a/src/api/common/generic_server.rs +++ b/src/api/common/generic_server.rs @@ -5,8 +5,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}; @@ -48,7 +46,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; @@ -57,11 +54,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> { @@ -249,13 +246,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)> { @@ -267,7 +262,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)> { |