remove async_trait used in generic_server.rs
This commit is contained in:
parent
620dc58560
commit
5475da8ea8
9 changed files with 3 additions and 25 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1301,7 +1301,6 @@ dependencies = [
|
|||
name = "garage_api_common"
|
||||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"crypto-common",
|
||||
|
@ -1332,7 +1331,6 @@ dependencies = [
|
|||
name = "garage_api_k2v"
|
||||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.21.7",
|
||||
"err-derive",
|
||||
"futures",
|
||||
|
@ -1358,7 +1356,6 @@ version = "1.0.1"
|
|||
dependencies = [
|
||||
"aes-gcm",
|
||||
"async-compression",
|
||||
"async-trait",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"chrono",
|
||||
|
@ -1468,7 +1465,6 @@ name = "garage_net"
|
|||
version = "1.0.1"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
"err-derive",
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::collections::HashMap;
|
|||
use std::sync::Arc;
|
||||
|
||||
use argon2::password_hash::PasswordHash;
|
||||
use async_trait::async_trait;
|
||||
|
||||
use http::header::{ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ALLOW};
|
||||
use hyper::{body::Incoming as IncomingBody, Request, Response, StatusCode};
|
||||
|
@ -221,7 +220,6 @@ impl AdminApiServer {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ApiHandler for AdminApiServer {
|
||||
const API_NAME: &'static str = "admin";
|
||||
const API_NAME_DISPLAY: &'static str = "Admin";
|
||||
|
|
|
@ -18,7 +18,6 @@ garage_model.workspace = true
|
|||
garage_table.workspace = true
|
||||
garage_util.workspace = true
|
||||
|
||||
async-trait.workspace = true
|
||||
bytes.workspace = true
|
||||
chrono.workspace = true
|
||||
crypto-common.workspace = true
|
||||
|
|
|
@ -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)> {
|
||||
|
|
|
@ -19,7 +19,6 @@ garage_table.workspace = true
|
|||
garage_util = { workspace = true, features = [ "k2v" ] }
|
||||
garage_api_common.workspace = true
|
||||
|
||||
async-trait.workspace = true
|
||||
base64.workspace = true
|
||||
err-derive.workspace = true
|
||||
tracing.workspace = true
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use hyper::{body::Incoming as IncomingBody, Method, Request, Response};
|
||||
use tokio::sync::watch;
|
||||
|
||||
|
@ -48,7 +46,6 @@ impl K2VApiServer {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ApiHandler for K2VApiServer {
|
||||
const API_NAME: &'static str = "k2v";
|
||||
const API_NAME_DISPLAY: &'static str = "K2V";
|
||||
|
|
|
@ -24,7 +24,6 @@ garage_api_common.workspace = true
|
|||
|
||||
aes-gcm.workspace = true
|
||||
async-compression.workspace = true
|
||||
async-trait.workspace = true
|
||||
base64.workspace = true
|
||||
bytes.workspace = true
|
||||
chrono.workspace = true
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use hyper::header;
|
||||
use hyper::{body::Incoming as IncomingBody, Request, Response};
|
||||
use tokio::sync::watch;
|
||||
|
@ -70,7 +68,6 @@ impl S3ApiServer {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ApiHandler for S3ApiServer {
|
||||
const API_NAME: &'static str = "s3";
|
||||
const API_NAME_DISPLAY: &'static str = "S3";
|
||||
|
|
|
@ -22,7 +22,6 @@ tokio.workspace = true
|
|||
tokio-util.workspace = true
|
||||
tokio-stream.workspace = true
|
||||
|
||||
async-trait.workspace = true
|
||||
serde.workspace = true
|
||||
rmp-serde.workspace = true
|
||||
hex.workspace = true
|
||||
|
|
Loading…
Add table
Reference in a new issue